Skip to content
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

Introducing additional processing options #59

Merged
merged 27 commits into from
Oct 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
72de7d6
Updated version
kdiers Apr 30, 2024
3e46791
Implemented status file and skip-existing option
kdiers May 3, 2024
ea28383
Updated documentation
kdiers May 3, 2024
9b8a9b6
Updated skip-existing option
kdiers May 17, 2024
8146283
Optionally write out fornix shape metrics
kdiers May 17, 2024
9146fb1
Added group-only, no-group options
kdiers May 27, 2024
021c0ae
Updated documentation
kdiers Jun 7, 2024
8be21ce
Updated documentation
kdiers Jun 13, 2024
34bbc64
Updated skip-existing, statusfile functionality
kdiers Jun 13, 2024
475d5ef
Updated group-only functionality
kdiers Jun 14, 2024
9fbcbbc
Fixed brainprint, lapy versions
kdiers Jul 25, 2024
7dde46b
Updated version
kdiers Jul 25, 2024
bb0363b
Updated readme, documentation
kdiers Jul 25, 2024
982f315
Updated docstring
kdiers Jul 25, 2024
53ab662
Applying ruff changes
kdiers Jul 25, 2024
c00a8c8
Applying isort changes
kdiers Jul 25, 2024
943b255
Applying black changes
kdiers Jul 25, 2024
c68b35b
Applying codespell changes
kdiers Jul 25, 2024
341f90e
Merge branch 'stable' into dev
m-reuter Sep 6, 2024
fcbba4f
bump action version and python to 3.10, drop build py3.8 and add 3.12
m-reuter Sep 6, 2024
917d982
add more rules to ruff and drop isort and black
m-reuter Sep 6, 2024
5fc3c0d
fix ruff B errors
m-reuter Sep 6, 2024
5354516
ignore line length for now
m-reuter Sep 6, 2024
7232038
fix typo
m-reuter Sep 6, 2024
204ba34
Merge pull request #62 from Deep-MI/workflows
m-reuter Sep 6, 2024
9abb85b
Fixes mutable default argument issues
kdiers Oct 15, 2024
9d126fa
Fixes typo
kdiers Oct 15, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,20 +15,19 @@ jobs:
fail-fast: false
matrix:
os: [ubuntu, macos, windows]
python-version: [3.8, 3.9, "3.10", "3.11"]
python-version: ["3.9", "3.10", "3.11", "3.12"]
name: ${{ matrix.os }} - py${{ matrix.python-version }}
runs-on: ${{ matrix.os }}-latest
defaults:
run:
shell: bash
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@v4
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
#architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
Expand Down
15 changes: 4 additions & 11 deletions .github/workflows/code-style.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,25 +14,18 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.9
uses: actions/setup-python@v4
uses: actions/checkout@v4
- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'
architecture: 'x64'
- name: Install dependencies
run: |
python -m pip install --progress-bar off --upgrade pip setuptools wheel
python -m pip install --progress-bar off .[style]
- name: Run Ruff
run: ruff check .
- name: Run isort
uses: isort/isort-action@master
- name: Run black
uses: psf/black@stable
with:
options: "--check --verbose"
version: "23.10.1"
- name: Run codespell
uses: codespell-project/actions-codespell@master
with:
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/doc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ jobs:
uses: actions/checkout@v4
with:
path: ./main
- name: Setup Python 3.9
uses: actions/setup-python@v4
- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: 3.9
python-version: '3.10'
architecture: 'x64'
- name: Install package
run: |
Expand Down Expand Up @@ -56,7 +56,7 @@ jobs:
name: doc-dev
path: ./doc-dev
- name: Deploy dev documentation
uses: peaceiris/actions-gh-pages@v3
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./doc-dev
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Setup Python 3.9
uses: actions/setup-python@v4
uses: actions/checkout@v4
- name: Setup Python 3.10
uses: actions/setup-python@v5
with:
python-version: '3.9'
python-version: '3.10'
architecture: 'x64'
- name: Install dependencies
run: |
Expand Down
5 changes: 5 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,11 @@

This is a document summarizing the changes that are associated with (major) updates and releases. Priority is given to changes that are relevant to the user, and those that introduce new features or break compatibility with prior versions.

## Version 2.1.0

- Added group-only, no-group options to allow for running the scripts at the individual or group level only. Default is to run at both levels.
- Added status file and skip-existing option to allow for incremental updates of a given output directory; additional cases or additional modules will be added. Existing ones will not be recomputed.

## Version 2.0.2

- This fixes an issue with the outlier module, which did not run for FastSurfer output due to incorrect expectations for names of stats files.
Expand Down
6 changes: 5 additions & 1 deletion DESCRIPTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,8 @@ run_fsqc --subjects_dir <directory> --output_dir <directory>
[--fornix] [--fornix-html] [--hippocampus]
[--hippocampus-html] [--hippocampus-label ... ]
[--hypothalamus] [--hypothalamus-html] [--shape]
[--outlier] [--fastsurfer] [-h] [--more-help]
[--outlier] [--fastsurfer] [--exit-on-error]
[--skip-existing] [-h] [--more-help]
[...]


Expand Down Expand Up @@ -194,6 +195,9 @@ optional arguments:
--exit-on-error terminate the program when encountering an error;
otherwise, try to continue with the next module or
case
--skip-existing skips processing for a given case if output
already exists, even with possibly different
parameters or settings.

getting help:
-h, --help display this help message and exit
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,9 @@ run_fsqc --subjects_dir <directory> --output_dir <directory>
[--fornix] [--fornix-html] [--hippocampus]
[--hippocampus-html] [--hippocampus-label ... ]
[--hypothalamus] [--hypothalamus-html] [--shape]
[--outlier] [--fastsurfer] [-h] [--more-help]
[--outlier] [--fastsurfer] [--no-group]
[--group-only] [--exit-on-error]
[--skip-existing] [-h] [--more-help]
[...]


Expand Down Expand Up @@ -263,9 +265,17 @@ optional arguments:
--outlier-table specify normative values (only in conjunction with
--outlier)
--fastsurfer use FastSurfer instead of FreeSurfer output
--no-group run script in subject-level mode. will compute
individual files and statistics, but not create
group-level summaries.
--group-only run script in group mode. will create group-level
summaries from existing inputs
--exit-on-error terminate the program when encountering an error;
otherwise, try to continue with the next module or
case
--skip-existing skips processing for a given case if output
already exists, even with possibly different
parameters or settings

getting help:
-h, --help display this help message and exit
Expand Down Expand Up @@ -395,7 +405,7 @@ Call `help(fsqc.run_fsqc)` for further usage info and additional options.

### As a Docker image

We provide a configuration files that can be used to create a Docker or
We provide configuration files that can be used to create a Docker or
Singularity image for the fsqc scripts. Documentation can be found on the
[Docker](docker/Docker.md) and [Singularity](singularity/Singularity.md) pages.

Expand Down Expand Up @@ -467,7 +477,7 @@ ___
all required packages will be installed automatically and manual installation
as detailed above will not be necessary.

- This software has been tested on Ubuntu 20.04.
- This software has been tested on Ubuntu 20.04 and 22.04.

- A working [FreeSurfer](https://freesurfer.net) installation (version 6 or
newer) is required for running the 'shape' module of this toolbox. Also make
Expand Down
2 changes: 1 addition & 1 deletion VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.2
2.1.0
2 changes: 1 addition & 1 deletion doc/Requirements.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Requirements
```
- If installing the toolbox as a Python package or if using the Docker image, all required packages will be installed automatically, and manual installation as detailed above will not be necessary.

- This software has been tested on Ubuntu 20.04.
- This software has been tested on Ubuntu 20.04 and Ubuntu 22.04.

- A working `FreeSurfer <https://freesurfer.net/>`_ installation (version 6 or newer) is required for running the 'shape' module of this toolbox. Also, make sure that FreeSurfer is sourced (i.e., FREESURFER_HOME is set as an environment variable) before running an analysis.

Expand Down
47 changes: 29 additions & 18 deletions doc/Usage.rst
Original file line number Diff line number Diff line change
Expand Up @@ -6,23 +6,25 @@ As a Command Line Tool

.. code-block:: sh

run_fsqc
--subjects_dir <directory>
run_fsqc
--subjects_dir <directory>
--output_dir <directory>
[--subjects SubjectID]
[--subjects SubjectID [SubjectID ...]]
[--subjects-file <file>] [--screenshots]
[--screenshots-html] [--surfaces] [--surfaces-html]
[--skullstrip] [--skullstrip-html]
[--fornix] [--fornix-html] [--hippocampus]
[--hippocampus-html] [--hippocampus-label ... ]
[--hypothalamus] [--hypothalamus-html] [--shape]
[--outlier] [--fastsurfer] [-h] [--more-help]
[--outlier] [--fastsurfer] [--no-group]
[--group-only] [--exit-on-error]
[--skip-existing] [-h] [--more-help]
[...]

Required Arguments:
-------------------
--subjects_dir <directory>
Subjects directory with a set of Freesurfer- or
Subjects directory with a set of Freesurfer- or
Fastsurfer-processed individual datasets.

--output_dir <directory>
Expand Down Expand Up @@ -88,9 +90,18 @@ As a Command Line Tool
--fastsurfer
Use FastSurfer instead of FreeSurfer output

--no-group
run script in subject-level mode. will compute individual files and statistics, but not create group-level summaries.

--group-only
run script in group mode. will create group-level summaries from existing inputs. needs to be run on output directory with already existing results.

--exit-on-error
Terminate the program when encountering an error; otherwise, try to continue with the next module or case

--skip-existing
skips processing for a given case if output already exists, even with possibly different parameters or settings

Getting Help:
-------------
-h, --help
Expand All @@ -102,34 +113,34 @@ As a Command Line Tool
---------------
--screenshots_base <image>
Filename of an image that should be used instead of
norm.mgz as the base image for the screenshots. Can be
an individual file (which would not be appropriate for
multi-subject analysis) or can be a file without
norm.mgz as the base image for the screenshots. Can be
an individual file (which would not be appropriate for
multi-subject analysis) or can be a file without
pathname and with the same filename across subjects within the 'mri'
subdirectory of an individual FreeSurfer results directory
subdirectory of an individual FreeSurfer results directory
(which would be appropriate for multi-subject analysis).

--screenshots_overlay <image>
Path to an image that should be used instead of aseg.mgz
as the overlay image for the screenshots can also be none.
Can be an individual file (which would not be appropriate
Path to an image that should be used instead of aseg.mgz
as the overlay image for the screenshots can also be none.
Can be an individual file (which would not be appropriate
for multi-subject analysis) or can be a file without pathname
and with the same filename across subjects within the 'mri' subdirectory
of an individual FreeSurfer results directory
of an individual FreeSurfer results directory
(which would be appropriate for multi-subject analysis).

--screenshots_surf <surf> [<surf> ...]
One or more surface files that should be used instead of
One or more surface files that should be used instead of
[lr]h.white and [lr]h.pial; can also be none.
Can be one or more individual file(s) (which would not
Can be one or more individual file(s) (which would not
be appropriate for multi-subject analysis) or
can be a (list of) file(s) without pathname and with the same
can be a (list of) file(s) without pathname and with the same
filename across subjects within the 'surf'
subdirectory of an individual FreeSurfer results directory
subdirectory of an individual FreeSurfer results directory
(which would be appropriate for multi-subject analysis).

--screenshots_views <view> [<view> ...]
One or more views to use for the screenshots in the form of
One or more views to use for the screenshots in the form of
x=<numeric> y=<numeric> and/or z=<numeric>.
Order does not matter. Default views are x=-10 x=10 y=0 z=0.

Expand Down
2 changes: 1 addition & 1 deletion fsqc/checkCCSize.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ def checkCCSize(subjects_dir, subject):
relative_cc = sum_cc / intracranial_volume

logging.info(
"Relative size of the corpus callosum is " + "{:.4}".format(relative_cc)
"Relative size of the corpus callosum is " + f"{relative_cc:.4}"
)

# Return
Expand Down
16 changes: 10 additions & 6 deletions fsqc/checkContrast.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,20 +49,23 @@ def checkContrast(subjects_dir, subject):
# Check if files exist
path_pct_lh = os.path.join(subjects_dir, subject, "surf", "lh.w-g.pct.mgh")
if not os.path.exists(path_pct_lh):
warnings.warn("WARNING: could not find " + path_pct_lh + ", returning NaNs")
warnings.warn("WARNING: could not find " + path_pct_lh + ", returning NaNs",
stacklevel = 2)
return numpy.nan

path_pct_rh = os.path.join(subjects_dir, subject, "surf", "rh.w-g.pct.mgh")
if not os.path.exists(path_pct_rh):
warnings.warn("WARNING: could not find " + path_pct_rh + ", returning NaNs")
warnings.warn("WARNING: could not find " + path_pct_rh + ", returning NaNs",
stacklevel = 2)
return numpy.nan

path_label_cortex_lh = os.path.join(
subjects_dir, subject, "label", "lh.cortex.label"
)
if not os.path.exists(path_label_cortex_lh):
warnings.warn(
"WARNING: could not find " + path_label_cortex_lh + ", returning NaNs"
"WARNING: could not find " + path_label_cortex_lh + ", returning NaNs",
stacklevel = 2
)
return numpy.nan

Expand All @@ -71,7 +74,8 @@ def checkContrast(subjects_dir, subject):
)
if not os.path.exists(path_label_cortex_rh):
warnings.warn(
"WARNING: could not find " + path_label_cortex_rh + ", returning NaNs"
"WARNING: could not find " + path_label_cortex_rh + ", returning NaNs",
stacklevel = 2
)
return numpy.nan

Expand All @@ -91,14 +95,14 @@ def checkContrast(subjects_dir, subject):
con_lh_std = numpy.std(con_lh)
con_lh_snr = con_lh_mean / con_lh_std
logging.info(
"WM/GM contrast SNR for the left hemisphere: " + "{:.4}".format(con_lh_snr)
"WM/GM contrast SNR for the left hemisphere: " + f"{con_lh_snr:.4}"
)

con_rh_mean = numpy.mean(con_rh)
con_rh_std = numpy.std(con_rh)
con_rh_snr = con_rh_mean / con_rh_std
logging.info(
"WM/GM contrast SNR for the right hemisphere: " + "{:.4}".format(con_rh_snr)
"WM/GM contrast SNR for the right hemisphere: " + f"{con_rh_snr:.4}"
)

# Return
Expand Down
14 changes: 8 additions & 6 deletions fsqc/checkRotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ def checkRotation(subjects_dir, subject):

if importlib.util.find_spec("transforms3d") is None:
warnings.warn(
"WARNING: 'transforms3d' package required for running this script, returning NaNs."
"WARNING: 'transforms3d' package required for running this script, returning NaNs.",
stacklevel = 2
)
return np.nan, np.nan, np.nan
else:
Expand All @@ -64,12 +65,13 @@ def checkRotation(subjects_dir, subject):
warnings.warn(
"WARNING: could not open "
+ os.path.join(subjects_dir, subject, "mri", "transforms", "talairach.lta")
+ ", returning NaNs."
+ ", returning NaNs.",
stacklevel = 2
)
return np.nan, np.nan, np.nan

with open(
os.path.join(subjects_dir, subject, "mri", "transforms", "talairach.lta"), "r"
os.path.join(subjects_dir, subject, "mri", "transforms", "talairach.lta")
) as datafile:
lines = datafile.readlines()

Expand Down Expand Up @@ -102,11 +104,11 @@ def checkRotation(subjects_dir, subject):

logging.info(
"Found Talairach rotation angles: x = "
+ "{:.3}".format(rot_x)
+ f"{rot_x:.3}"
+ ", y = "
+ "{:.3}".format(rot_y)
+ f"{rot_y:.3}"
+ ", z = "
+ "{:.3}".format(rot_z)
+ f"{rot_z:.3}"
+ " radians.",
)

Expand Down
Loading