-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add initial FastSurfer interface (WIP) #280
base: master
Are you sure you want to change the base?
Conversation
Dockerfile building from a PyTorch base image to facilitate running FastSurfer (GPU). Testing this image for FastSurfer - once built as smriprep:fastsurfer_dev - can be performed with the following command: docker run --gpus all --entrypoint /bin/bash -v /path/to/bids:/data -v /path/to/bids/derivatives/fastsurfer:/output -v /path/to/freesurfer/license:/fs60/license --rm --user `id -u` smriprep:fastsurfer_dev /opt/FastSurfer/run_fastsurfer.sh --fs_license /fs60/license --t1 /data/sourcedata/sub-SUBJECT/ses-SESSION/anat/sub-SUBJECT_ses-SESSION_T1w.nii.gz --sid sub-SUBJECT --sd /output
Checks FreeSurfer subjects dir for presence of files in mri/ with names indicating processing with FastSurfer, and returns a boolean fastsurfer_bool to indicate that FastSurfer is being used instead of Freesurfer. For development purposes, this also touches files that are expected outputs of Freesurfer, but not produced by default in FastSurfer. (Addresses nipreps#278 & Deep-MI/FastSurfer#21)
Add logger for the check_fastsurfer function to indicate if evidence of FastSurfer surface recon was used to generate the given subjects_dir
Adds the check_fastsurfer function call to log FastSurfer outputs detected in subjects_dir and touch mri/aseg.auto_noCCseg.label_intensities.txt to prevent failure in surfaces.py as a temporary fix for nipreps#278
Removes currently unused fastsurfer_bool variable
Adds FastSurfer argument to support FastSurfer as a surface processing option (nipreps#278)
Add citations for FastSurfer: 1mm isotropic original paper = fastsurfer, 2022 hires version (NOT YET IMPLEMENTED) = fastsurfer_hires
Adds python wrapper for FastSurfer (nipreps#278)
Adds affiliation to contributors for work regarding nipreps#278
Add researcher type
Address PEP8 blankspaces flag
Address PEP8
Address PEP8
Fix fail to build docs in CircleCI observed in testing draft changes made to PR nipreps#280. ``` #!/bin/bash -eo pipefail make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" html make: Entering directory '/tmp/gh-pages/docs' PYTHONPATH=/tmp/gh-pages sphinx-build -b html -d _build/no_version_html/doctrees -W . _build/no_version_html/html Traceback (most recent call last): File "/home/circleci/.local/bin/sphinx-build", line 5, in <module> from sphinx.cmd.build import main File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/cmd/build.py", line 23, in <module> from sphinx.application import Sphinx File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/application.py", line 42, in <module> from sphinx.highlighting import lexer_classes, lexers File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/highlighting.py", line 30, in <module> from sphinx.ext import doctest File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/ext/doctest.py", line 28, in <module> from sphinx.builders import Builder File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 24, in <module> from sphinx.io import read_doc File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/io.py", line 42, in <module> from sphinx.util.rst import append_epilog, docinfo_re, prepend_prolog File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/util/rst.py", line 22, in <module> from jinja2 import environmentfilter ImportError: cannot import name 'environmentfilter' from 'jinja2' (/home/circleci/.local/lib/python3.8/site-packages/jinja2/__init__.py) make: *** [Makefile:61: html] Error 1 make: Leaving directory '/tmp/gh-pages/docs' Exited with code exit status 2 CircleCI received exit code 2 ``` From suggested fix for similar behavior: mkdocs/mkdocs#2799
Fix fail to build docs in CircleCI observed in testing draft changes made to PR nipreps#280. ``` #!/bin/bash -eo pipefail make -C docs SPHINXOPTS="-W" BUILDDIR="_build/no_version_html" html make: Entering directory '/tmp/gh-pages/docs' PYTHONPATH=/tmp/gh-pages sphinx-build -b html -d _build/no_version_html/doctrees -W . _build/no_version_html/html Traceback (most recent call last): File "/home/circleci/.local/bin/sphinx-build", line 5, in <module> from sphinx.cmd.build import main File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/cmd/build.py", line 23, in <module> from sphinx.application import Sphinx File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/application.py", line 42, in <module> from sphinx.highlighting import lexer_classes, lexers File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/highlighting.py", line 30, in <module> from sphinx.ext import doctest File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/ext/doctest.py", line 28, in <module> from sphinx.builders import Builder File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/builders/__init__.py", line 24, in <module> from sphinx.io import read_doc File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/io.py", line 42, in <module> from sphinx.util.rst import append_epilog, docinfo_re, prepend_prolog File "/home/circleci/.local/lib/python3.8/site-packages/sphinx/util/rst.py", line 22, in <module> from jinja2 import environmentfilter ImportError: cannot import name 'environmentfilter' from 'jinja2' (/home/circleci/.local/lib/python3.8/site-packages/jinja2/__init__.py) make: *** [Makefile:61: html] Error 1 make: Leaving directory '/tmp/gh-pages/docs' Exited with code exit status 2 CircleCI received exit code 2 ``` From suggested fix for similar behavior: mkdocs/mkdocs#2799
From commit #5090a7d
Ah, I'm really sorry about the slow response times. I think I saw this in the middle of something else and then the notification got buried. Do you want help resolving merge conflicts? |
No worries! Any help with the merge conflicts would be great, thanks! |
Install FastSurfer dependencies in conda environment before installing smriprep wheels
Incorporate updates from nipreps master branch
@effigies, no worries! A lot has been updated for both toolkits in the meantime, so I processed a dataset with the latest FastSurfer (v2.2.0) and then used it as an input for sMRIPrep v0.15.0 with the
|
Looks like midthickness worked, but templateflow failed to download the whole file either during image creation or at runtime. |
Ah, my mistake. The midthickness issue popped up when I used output from an older version of FastSurfer (version < 2.X). I pulled a local copy of the templates with datalad and the workflow completes now.
In my current role, I do not have the throughput to bring this PR up to date. If you know anyone who would be interested in doing so, I would be happy to help. Please let me know what you think! I appreciate the feedback and guidance on this. |
Supports #278
Adds FastSurfer detection utility incorporated to smriprep.workflows.anatomical.py to fix failure when providing FastSurfer subjects dir as existing Freesurfer subjects dir. This utility
check_fastsurfer
employs a fix of touching a labels intensity file expected by Freesurfer, but not currently produced by FastSurfer. FastSurfer outputs from running with the--surfreg
flag can then be used to successfully complete the sMRIPrep workflow.Adds draft of basic interface for FastSurfer to smriprep interfaces, which work on my test datasets when running on the modified Docker or Singularity images (
see f8972da for changes to DockerfileEDIT: this Dockerfile has been replaced with a version built on Ubuntu 20.04 that passes CircleCI build).To support the using the FastSurfer interface/wrapper to run FastSurfer as part of sMRIPrep, this PR also adds the following argument to the cli (https://github.com/pcamach2/smriprep/blob/pcamach2-fastsurfer-patch-dev/smriprep/cli/run.py)
As mentioned in the above issue, I am wondering where best to split workflow behavior (in anatomical.py?) based on the above argument. Would it be better to make separate surfaces.py versions for FastSurfer and FreeSurfer or just different workflows within a unified surfaces.py? Note that if a dataset includes FLAIR or T2w, FreeSurfer will still want to process them automatically even if there is FastSurfer output (this adds on a few hours).