Skip to content

Commit

Permalink
update to main (#10)
Browse files Browse the repository at this point in the history
* Add workbench to qsirecon (#6)

* Update Dockerfile

* Update Dockerfile

* update amico

* continued

* update mamba repo

* Install c3d with mamba (#8)

* Install c3d and ants with mamba.

* Update Dockerfile_Micromamba

* Drop ANTS install.

* Reformat AtlasPack into a BIDS-Atlas dataset (#7)

Reformat AtlasPack into a BIDS-Atlas dataset.

* Reorganize QSIRecon atlases into a BIDS-Atlas dataset (#9)

* Use new version of QSIRecon atlases.

* Change location of AtlasPack.

---------

Co-authored-by: Matt Cieslak <[email protected]>
Co-authored-by: Taylor Salo <[email protected]>
  • Loading branch information
3 people authored Oct 24, 2024
1 parent 0ce99d7 commit b4a1ec6
Show file tree
Hide file tree
Showing 6 changed files with 203 additions and 26 deletions.
14 changes: 14 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,13 @@ build: &build
jobs:

build_Micromamba:
environment:
VERSION_TAG: "TAG_MICROMAMBA"
IMG_NAME: "qsirecon-micromamba"
BUILD_FILE: "Dockerfile_Micromamba"
<<: *build

build:
environment:
TZ: "/usr/share/zoneinfo/America/New_York"
Expand Down Expand Up @@ -82,9 +89,16 @@ jobs:

workflows:
version: 2

build_test_deploy:
jobs:
- build_Micromamba:
filters:
tags:
only: /.*/
- build:
requires:
- build_Micromamba
filters:
tags:
only: /.*/
47 changes: 22 additions & 25 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ ARG TAG_TORTOISE
ARG TAG_TORTOISECUDA

# COPY can't handle variables, so here we go
FROM pennlinc/qsirecon-micromamba:${TAG_MICROMAMBA} as build_micromamba
FROM pennbbl/qsiprep-freesurfer:${TAG_FREESURFER} as build_freesurfer
FROM pennbbl/qsiprep-ants:${TAG_ANTS} as build_ants
FROM pennbbl/qsiprep-mrtrix3:${TAG_MRTRIX3} as build_mrtrix3
FROM pennbbl/qsiprep-3tissue:${TAG_3TISSUE} as build_3tissue
FROM pennbbl/qsiprep-dsistudio:${TAG_DSISTUDIO} as build_dsistudio
FROM pennbbl/qsiprep-micromamba:${TAG_MICROMAMBA} as build_micromamba
FROM pennbbl/qsiprep-afni:${TAG_AFNI} as build_afni
FROM pennbbl/qsiprep-drbuddi:${TAG_TORTOISE} as build_tortoise
FROM pennbbl/qsiprep-drbuddicuda:${TAG_TORTOISE} as build_tortoisecuda
Expand Down Expand Up @@ -136,16 +136,6 @@ RUN apt-get update -qq \
&& ldconfig \
&& apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

RUN echo "Downloading Convert3D ..." \
&& mkdir -p /opt/convert3d-nightly \
&& curl -fsSL --retry 5 https://sourceforge.net/projects/c3d/files/c3d/Nightly/c3d-nightly-Linux-x86_64.tar.gz/download \
| tar -xz -C /opt/convert3d-nightly --strip-components 1 \
--exclude "c3d-1.0.0-Linux-x86_64/lib" \
--exclude "c3d-1.0.0-Linux-x86_64/share" \
--exclude "c3d-1.0.0-Linux-x86_64/bin/c3d_gui"
ENV C3DPATH="/opt/convert3d-nightly" \
PATH="/opt/convert3d-nightly/bin:$PATH"

# Prepare environment
RUN apt-get update && \
apt-get install -y --no-install-recommends \
Expand Down Expand Up @@ -221,26 +211,33 @@ RUN python fetch_templates.py && \
find $HOME/.cache/templateflow -type d -exec chmod go=u {} + && \
find $HOME/.cache/templateflow -type f -exec chmod go=u {} +

# Precaching AtlasPack atlases
RUN mkdir /AtlasPack
COPY --from=atlaspack /AtlasPack/tpl-fsLR_*.dlabel.nii /AtlasPack/
COPY --from=atlaspack /AtlasPack/tpl-MNI152NLin6Asym_*.nii.gz /AtlasPack/
COPY --from=atlaspack /AtlasPack/tpl-MNI152NLin2009cAsym_*.nii.gz /AtlasPack/
COPY --from=atlaspack /AtlasPack/atlas-4S*.tsv /AtlasPack/
COPY --from=atlaspack /AtlasPack/*.json /AtlasPack/

# Make it ok for singularity on CentOS
RUN strip --remove-section=.note.ABI-tag /opt/qt512/lib/libQt5Core.so.5.12.8 \
&& ldconfig

# Prepare atlases
RUN mkdir /atlas

# Download the AtlasPack atlases
RUN mkdir /atlas/AtlasPack
COPY --from=atlaspack /AtlasPack/tpl-fsLR_*.dlabel.nii /atlas/AtlasPack/
COPY --from=atlaspack /AtlasPack/tpl-MNI152NLin6Asym_*.nii.gz /atlas/AtlasPack/
COPY --from=atlaspack /AtlasPack/tpl-MNI152NLin2009cAsym_*.nii.gz /atlas/AtlasPack/
COPY --from=atlaspack /AtlasPack/atlas-4S*.tsv /atlas/AtlasPack/
COPY --from=atlaspack /AtlasPack/*.json /atlas/AtlasPack/
ENV QSIRECON_ATLASPACK /atlas/AtlasPack

# Reformat AtlasPack into a BIDS dataset
COPY scripts/fix_atlaspack.py fix_atlaspack.py
RUN python fix_atlaspack.py && rm fix_atlaspack.py

# Download the built-in atlases
ENV QSIRECON_ATLAS /atlas/qsirecon_atlases
RUN bash -c \
'mkdir /atlas \
&& cd /atlas \
&& wget -nv https://upenn.box.com/shared/static/40f2m6dzzd8co5jx3cxpgct3zkkwm5d3.xz \
&& tar xvfJm 40f2m6dzzd8co5jx3cxpgct3zkkwm5d3.xz \
&& rm 40f2m6dzzd8co5jx3cxpgct3zkkwm5d3.xz'
'cd /atlas \
&& wget -nv https://upenn.box.com/shared/static/5k1tvg6soelxdhi9nvrkry6w0z49ctne.xz \
&& tar xvfJm 5k1tvg6soelxdhi9nvrkry6w0z49ctne.xz \
&& rm 5k1tvg6soelxdhi9nvrkry6w0z49ctne.xz'
ENV QSIRECON_ATLAS /atlas/qsirecon_atlases

# Download the PyAFQ atlases
RUN pyAFQ download
Expand Down
62 changes: 62 additions & 0 deletions Dockerfile_Micromamba
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
# Copied from: fMRIPrep Docker Container Image distribution
#
# MIT License
#
# Copyright (c) 2021 The NiPreps Developers
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in all
# copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.

FROM nvidia/cuda:11.2.2-devel-ubuntu18.04
ARG TAG_ANTS

RUN apt-get update && \
apt-get install -y --no-install-recommends \
ca-certificates \
curl \
libblas-dev \
liblapack-dev \
build-essential \
libglu1-mesa-dev \
bzip2 \
libgomp1 \
wget

# Create a shared $HOME directory
RUN useradd -m -s /bin/bash -G users qsiprep
WORKDIR /home/qsiprep
ENV HOME="/home/qsiprep"

WORKDIR /
RUN echo "2024.04.11"
RUN curl -Ls https://micro.mamba.pm/api/micromamba/linux-64/latest | tar -xvj bin/micromamba

ENV MAMBA_ROOT_PREFIX="/opt/conda" \
MAMBA_NO_LOW_SPEED_LIMIT=1 \
PIP_DEFAULT_TIMEOUT=100

COPY qsirecon_env.yml /tmp/env.yml

WORKDIR /tmp
RUN micromamba config set extract_threads 1
RUN micromamba create -vv -y -f /tmp/env.yml
ENV PATH=/opt/conda/envs/qsiprep/bin:$PATH
RUN micromamba clean -y -a

RUN mkdir -p ${HOME}/.dipy \
&& python -c "import amico; amico.core.setup()"
45 changes: 45 additions & 0 deletions qsirecon_env.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: qsiprep
channels:
- conda-forge
dependencies:
- mkl
- mkl-service
- numpy=1.23.5
- scipy=1.11
- fury
# Workflow dependencies: Convert3d
- convert3d=1.4
# Python dependencies
- python=3.10
- pip
- pip:
- bids-validator==1.14.1
- coverage
- dipy==1.8.0
- dmri-amico==2.0.3
- jinja2==3.0.3
- keras==2.8.0
- matplotlib==3.8.3
- nibabel==5.2.1
- nilearn==0.10.1
- nipype==1.8.6
- niworkflows >=1.9,<= 1.10
- numpy==1.23.5
- pandas==1.5.3
- pillow==10.3.0
- pyafq==1.3.2
- pytest==8.2.2
- pytest-cov==5.0.0
- pytest-env==1.1.3
- protobuf==3.19.6
- scikit-image==0.22.0
- scikit-learn==1.4.0
- sentry-sdk==1.40.6
- simpleitk==2.3.1
- sqlalchemy==2.0.27
- templateflow==23.1.0
- tensorflow-gpu==2.8.4
- torch==1.13.1
- transforms3d==0.4.1
- trx-python==0.2.9
- xvfbwrapper==0.2.9
59 changes: 59 additions & 0 deletions scripts/fix_atlaspack.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
"""Convert the AtlasPack folder into a BIDS dataset."""

import json
import os
import re
import shutil

if __name__ == "__main__":
# Where all the files are located
in_dir = os.getenv("QSIRECON_ATLASPACK")

with open(os.path.join(in_dir, "dataset_description.json"), "w") as fo:
json.dump(
{"Name": "AtlasPack", "BIDSVersion": "1.9.0", "DatasetType": "atlas"},
fo,
)

# Define patterns and corresponding target formats
patterns = [
(r"atlas-([a-zA-Z0-9+]+)_dseg.tsv", r"atlas-\1/atlas-\1_dseg.tsv"),
(
r"tpl-MNI152NLin6Asym_atlas-([a-zA-Z0-9+]+)_res-01_dseg.nii.gz",
r"atlas-\1/atlas-\1_space-MNI152NLin6Asym_res-01_dseg.nii.gz",
),
(
r"tpl-MNI152NLin2009cAsym_atlas-([a-zA-Z0-9+]+)_res-01_dseg.nii.gz",
r"atlas-\1/atlas-\1_space-MNI152NLin2009cAsym_res-01_dseg.nii.gz",
),
(
r"tpl-fsLR_atlas-([a-zA-Z0-9+]+)_den-91k_dseg.dlabel.nii",
r"atlas-\1/atlas-\1_space-fsLR_den-91k_dseg.dlabel.nii",
),
(
r"tpl-MNI152NLin6Asym_atlas-([a-zA-Z0-9+]+)_dseg.json",
r"atlas-\1/atlas-\1_space-MNI152NLin6Asym_res-01_dseg.json",
),
(
r"tpl-MNI152NLin2009cAsym_atlas-([a-zA-Z0-9+]+)_dseg.json",
r"atlas-\1/atlas-\1_space-MNI152NLin2009cAsym_res-01_dseg.json",
),
(
r"tpl-fsLR_atlas-([a-zA-Z0-9+]+)_dseg.json",
r"atlas-\1/atlas-\1_space-fsLR_den-91k_dseg.json",
),
]

for pattern, target_format in patterns:
files = [f for f in os.listdir(in_dir) if re.search(pattern, f)]
for filename in files:
atlas_name = re.findall(pattern, filename)[0]
target_dir = os.path.join(in_dir, f"atlas-{atlas_name}")
target_path = os.path.join(in_dir, target_format.replace(r"\1", atlas_name))

# Create target directory if it doesn't exist
os.makedirs(target_dir, exist_ok=True)

# Move and rename the file
shutil.move(os.path.join(in_dir, filename), target_path)
print(f"Moved {filename} to {target_path}")
2 changes: 1 addition & 1 deletion setup_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export TAG_ANTS=24.4.24
export TAG_MRTRIX3=24.4.24
export TAG_3TISSUE=24.4.24
export TAG_DSISTUDIO=24.7.4
export TAG_MICROMAMBA=24.7.1
export TAG_MICROMAMBA=24.10.1
export TAG_AFNI=23.3.2
export TAG_TORTOISE=24.4.29
export TAG_TORTOISECUDA=24.4.29
Expand Down

0 comments on commit b4a1ec6

Please sign in to comment.