-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from gagnonanthony/feat/mcribs
New infant segmentation pipeline. New module to format labels from the Desikan-Killiany atlas. Tissue-specific fodf outputs. Infant surface reconstruction. New docker image for M-CRIB-S and InfantFS.
- Loading branch information
Showing
53 changed files
with
3,082 additions
and
1,464 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: fsl | ||
channels: | ||
- https://fsl.fmrib.ox.ac.uk/fsldownloads/fslconda/public/ | ||
- conda-forge | ||
dependencies: | ||
- python =3.11 | ||
- mkl=2023.2.0 | ||
- mkl-service=2.4.0 | ||
# Base scientific python stack; required by FSL, so pinned here | ||
- numpy=1.26 | ||
- scipy=1.11 | ||
- matplotlib=3.8 | ||
- pandas=2.2 | ||
- h5py=3.10 | ||
- nitime=0.10 | ||
- scikit-image=0.22 | ||
- scikit-learn=1.4 | ||
# FSL dependencies. | ||
- fsl-bet2=2111.4 | ||
- fsl-flirt=2111.2 | ||
- fsl-fast4=2111.3 | ||
- fsl-fugue=2201.4 | ||
- fsl-mcflirt=2111.0 | ||
- fsl-miscmaths=2203.2 | ||
- fsl-topup=2203.2 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
ARG BASE_IMAGE=ubuntu:jammy-20240405 | ||
|
||
# Older Python to support legacy MCRIBS (taken from nibabies Dockerfile) | ||
FROM python:3.6.15-slim AS pyenv | ||
RUN pip install --no-cache-dir numpy nibabel scipy pandas numexpr contextlib2 imageio \ | ||
&& cp /usr/lib/x86_64-linux-gnu/libffi.so.7* /usr/local/lib | ||
|
||
# Download FSL. | ||
FROM ${BASE_IMAGE} AS build-fsl | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
build-essential \ | ||
binutils \ | ||
bzip2 \ | ||
ca-certificates \ | ||
curl \ | ||
unzip \ | ||
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
WORKDIR / | ||
RUN echo "2024.04.25" && curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj | ||
ENV MAMBA_ROOT_PREFIX="/opt/conda" | ||
|
||
# Fetch the FSL environment | ||
COPY fsl.yml fsl.yml | ||
RUN micromamba create -y -f fsl.yml && \ | ||
micromamba clean --all --yes | ||
ENV PATH="/opt/conda/envs/fsl/bin:$PATH" | ||
|
||
# Set a stage for the build | ||
FROM ${BASE_IMAGE} AS runtime | ||
|
||
ENV DEBIAN_FRONTEND="noninteractive" \ | ||
LANG="en_US.UTF-8" \ | ||
LC_ALL="en_US.UTF-8" | ||
|
||
RUN apt-get update && \ | ||
apt-get install -y --no-install-recommends \ | ||
apt-utils \ | ||
bc \ | ||
build-essential \ | ||
ca-certificates \ | ||
curl \ | ||
git \ | ||
gnupg \ | ||
libtool \ | ||
locales \ | ||
lsb-release \ | ||
tcsh \ | ||
netbase \ | ||
unzip \ | ||
xvfb \ | ||
# MCRIBS-required | ||
libboost-dev \ | ||
libeigen3-dev \ | ||
libflann-dev \ | ||
libgl1-mesa-dev \ | ||
libglu1-mesa-dev \ | ||
libssl-dev \ | ||
libxt-dev \ | ||
zlib1g-dev && \ | ||
locale-gen en_US.UTF-8 && \ | ||
apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/* | ||
|
||
# Configure PPAs for libpng12 and libxp6 | ||
RUN GNUPGHOME=/tmp gpg --keyserver hkps://keyserver.ubuntu.com --no-default-keyring --keyring /usr/share/keyrings/linuxuprising.gpg --recv 0xEA8CACC073C3DB2A \ | ||
&& GNUPGHOME=/tmp gpg --keyserver hkps://keyserver.ubuntu.com --no-default-keyring --keyring /usr/share/keyrings/zeehio.gpg --recv 0xA1301338A3A48C4A \ | ||
&& echo "deb [signed-by=/usr/share/keyrings/linuxuprising.gpg] https://ppa.launchpadcontent.net/linuxuprising/libpng12/ubuntu jammy main" > /etc/apt/sources.list.d/linuxuprising.list \ | ||
&& echo "deb [signed-by=/usr/share/keyrings/zeehio.gpg] https://ppa.launchpadcontent.net/zeehio/libxp/ubuntu jammy main" > /etc/apt/sources.list.d/zeehio.list | ||
|
||
# Install ANTs | ||
COPY --from=gagnonanthony/ants@sha256:0abd03bc59c10ea4a93e399d07c5e4019cf8eb89963a54e050f209ed73722dce /opt/ants /opt/ants | ||
ENV PATH="/opt/ants/bin:$PATH" \ | ||
ANTSPATH="/opt/ants" \ | ||
LD_LIBRARY_PATH="/opt/ants/lib:$LD_LIBRARY_PATH" | ||
|
||
# Install FreeSurfer (with Infant Module) | ||
COPY --from=nipreps/freesurfer@sha256:3b895fc732a7080374a15c4f976510f39c0c48dc76c030ab27316febd5e419ee /opt/freesurfer /opt/freesurfer | ||
ENV FREESURFER_HOME="/opt/freesurfer" | ||
ENV SUBJECTS_DIR="$FREESURFER_HOME/subjects" \ | ||
FUNCTIONALS_DIR="$FREESURFER_HOME/sessions" \ | ||
MNI_DIR="$FREESURFER_HOME/mni" \ | ||
LOCAL_DIR="$FREESURFER_HOME/local" \ | ||
MINC_BIN_DIR="$FREESURFER_HOME/mni/bin" \ | ||
MINC_LIB_DIR="$FREESURFER_HOME/mni/lib" \ | ||
MNI_DATAPATH="$FREESURFER_HOME/mni/data" \ | ||
FSL_DIR=${FSLDIR} \ | ||
FREESURFER="/opt/freesurfer" | ||
ENV PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \ | ||
MNI_PERL5LIB="$MINC_LIB_DIR/perl5/5.8.5" \ | ||
PATH="$FREESURFER_HOME/bin:$FREESURFER_HOME/tktools:$MINC_BIN_DIR:$PATH" | ||
|
||
# Install MCRIBS from nipreps (with legacy Python) | ||
COPY --from=gagnonanthony/mcribs@sha256:12ddd74a0d47f055bea4bb19cc0df5b39d0b3ee2aa76d4276d4bfea6f169b2b5 /opt/MCRIBS/ /opt/MCRIBS | ||
COPY --from=pyenv /usr/local/lib/ /usr/local/lib/ | ||
COPY --from=pyenv /usr/local/bin/python3 /opt/MCRIBS/bin/python | ||
ENV PATH="/opt/MCRIBS/bin:/opt/MCRIBS/MIRTK/MIRTK-install/bin:/opt/MCRIBS/MIRTK/MIRTK-install/lib/tools:${PATH}" \ | ||
LD_LIBRARY_PATH="/opt/MCRIBS/lib:/opt/MCRIBS/ITK/ITK-install/lib:/opt/MCRIBS/VTK/VTK-install/lib:/opt/MCRIBS/MIRTK/MIRTK-install/lib:/usr/local/lib:${LD_LIBRARY_PATH}" \ | ||
MCRIBS_HOME="/opt/MCRIBS" \ | ||
PYTHONPATH="/opt/MCRIBS/lib/python:/usr/local/lib/python3.6/site-packages/:${PYTHONPATH}" | ||
|
||
# Install FSL | ||
COPY --from=build-fsl /bin/micromamba /bin/micromamba | ||
COPY --from=build-fsl /opt/conda/envs/fsl /opt/conda/envs/fsl | ||
ENV MAMBA_ROOT_PREFIX="/opt/conda" \ | ||
PATH="${PATH}:/opt/conda/envs/fsl/bin" \ | ||
CPATH="/opt/conda/envs/fsl/include:${CPATH}" \ | ||
LD_LIBRARY_PATH="/opt/conda/envs/fsl/lib:${LD_LIBRARY_PATH}" \ | ||
CONDA_PYTHON="/opt/conda/envs/fsl/bin/python" | ||
|
||
# FSL environment. | ||
ENV LANG="C.UTF-8" \ | ||
LC_ALL="C.UTF-8" \ | ||
PYTHONNOUSERSITE=1 \ | ||
FSLDIR="/opt/conda/envs/fsl" \ | ||
FSLOUTPUTTYPE="NIFTI_GZ" \ | ||
FSLMULTIFILEQUIT="TRUE" \ | ||
FSLLOCKDIR="" \ | ||
FSLMACHINELIST="" \ | ||
FSLREMOTECALL="" \ | ||
FSLGECUDAQ="cuda.q" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
#!/bin/python | ||
|
||
import argparse | ||
import logging | ||
|
||
import pandas as pd | ||
|
||
def _build_arg_parser(): | ||
p = argparse.ArgumentParser(description=__doc__, | ||
formatter_class=argparse.RawTextHelpFormatter) | ||
|
||
p.add_argument('-i', '--input', required=True, | ||
help='Input freesurfer stats file (.stats)') | ||
p.add_argument('-o', '--output', required=True, | ||
help='Output tsv file') | ||
|
||
p.add_argument('-m', '--measure', required=True, | ||
help='Measure to extract from stats file', | ||
choices=['GrayVol', 'SurfArea', 'ThickAvg']) | ||
p.add_argument('-s', '--subject', required=True, | ||
help='Subject ID') | ||
|
||
return p | ||
|
||
|
||
def main(): | ||
parser = _build_arg_parser() | ||
args = parser.parse_args() | ||
logging.getLogger().setLevel(logging.INFO) | ||
|
||
# Load stats file. | ||
df = pd.read_csv(args.input) | ||
|
||
# Freesurfer stats file have regions as rows and measures as columns, | ||
# need to transpose it with the desired measure. | ||
df_m = df.loc[:, ["StructName", args.measure]].T | ||
|
||
# Setting the first row as the column names. | ||
df_m.columns = df_m.iloc[0] | ||
|
||
# Dropping the first row. | ||
df_m = df_m[1:] | ||
|
||
# Replace first column name with "Sample" and add subject ID. | ||
df_m.columns.name = "Sample" | ||
df_m.index = [args.subject] | ||
|
||
# Dropping the medial wall column. | ||
df_m = df_m.drop(columns="Medial_Wall") | ||
|
||
# Save to tsv. | ||
df_m.to_csv(args.output, sep='\t', index=True, header=True) | ||
|
||
|
||
if __name__ == '__main__': | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.