8000 FIX: AFNI TSNR calculation, ADD: BlurToFWHM, ADD: testing outputs against reference by Shotgunosine · Pull Request #280 · poldracklab/fitlins · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

FIX: AFNI TSNR calculation, ADD: BlurToFWHM, ADD: testing outputs against reference #280

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

Merged
merged 61 commits into from
Feb 25, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
d023e6e
fix afni tsnr calculation
Shotgunosine Dec 1, 2020
63e45e9
fix afni tsnr calculation
Shotgunosine Dec 1, 2020
f8b679b
fix smoothing
Shotgunosine Dec 22, 2020
046db49
fix tsnr add blurtofwhm
Shotgunosine Dec 22, 2020
7452c83
add smoothing_type
Shotgunosine Dec 22, 2020
7ed90bb
add smoothing_type
Shotgunosine Dec 22, 2020
4ed2aaf
add blurto as smoothing type
Shotgunosine Jan 4, 2021
408e9c9
remove old tsnr code
Shotgunosine Jan 4, 2021
9b82a4a
RF: Use BIDSLayoutIndexer, requiring PyBIDS 0.12.4
effigies Dec 7, 2020
fca81fd
RF: nistats -> nilearn.glm
effigies Dec 7, 2020
280c945
add blurto as smoothing type
Shotgunosine Jan 4, 2021
9e82c62
ADD test fitlins outputs against reference result
Shotgunosine Jan 28, 2021
e7cb3b7
ADD readme for new tests
Shotgunosine Jan 28, 2021
e569c05
FIX tests on circle ci to use new tests
Shotgunosine Jan 28, 2021
7ec063b
fix afni tsnr calculation
S 8000 hotgunosine Dec 1, 2020
a8bc861
fix afni tsnr calculation
Shotgunosine Dec 1, 2020
be61e93
fix smoothing
Shotgunosine Dec 22, 2020
622769d
fix tsnr add blurtofwhm
Shotgunosine Dec 22, 2020
c42cad0
add smoothing_type
Shotgunosine Dec 22, 2020
3adb57d
add smoothing_type
Shotgunosine Dec 22, 2020
af888ef
add blurto as smoothing type
Shotgunosine Jan 4, 2021
ab57b38
remove old tsnr code
Shotgunosine Jan 4, 2021
401c2a4
RF: Use BIDSLayoutIndexer, requiring PyBIDS 0.12.4
effigies Dec 7, 2020
965db6f
RF: nistats -> nilearn.glm
effigies Dec 7, 2020
867006a
add blurto as smoothing type
Shotgunosine Jan 4, 2021
7d98300
ADD test fitlins outputs against reference result
Shotgunosine Jan 28, 2021
67a6a14
ADD readme for new tests
Shotgunosine Jan 28, 2021
49abed8
FIX tests on circle ci to use new tests
Shotgunosine Jan 28, 2021
665554a
fix merge conflict
Shotgunosine Jan 28, 2021
55e9d33
fix circlci config
Shotgunosine Jan 28, 2021
dd3e0f5
fix PEP8 issues
Shotgunosine Jan 28, 2021
5e154e1
fix circleci config
Shotgunosine Jan 28, 2021
be414a8
fix circleci
Shotgunosine Jan 28, 2021
497ca9c
fix circleci
Shotgunosine Jan 28, 2021
590518a
fix blur parameter check
Shotgunosine Jan 28, 2021
7a59d9c
fix circleci
Shotgunosine Jan 29, 2021
9289705
merge origin master
Shotgunosine Jan 29, 2021
c47a04b
clean up merge marker
Shotgunosine Jan 29, 2021
d954bf2
dataset description should use indent=2
Shotgunosine Jan 29, 2021
16ea969
fix coverage paths
Shotgunosine Jan 29, 2021
057586c
test dataset description properties
Shotgunosine Jan 29, 2021
0d65966
make sure to update datalad dataset
Shotgunosine Jan 29, 2021
12aa6cd
make sure to update datalad dataset
Shotgunosine Jan 29, 2021
45d7879
fix coverage.yml path
Shotgunosine Jan 29, 2021
bf43f4a
wrap pytest in coverage
Shotgunosine Jan 29, 2021
b64c7a4
fix circleci
Shotgunosine Feb 1, 2021
bd1adbc
fix circleci
Shotgunosine Feb 1, 2021
65b1481
change to ds003-v1
Shotgunosine Feb 9, 2021
ddc5a98
fix coverage inlcusions
Shotgunosine Feb 9, 2021
af167d1
fix coverage
Shotgunosine Feb 9, 2021
473882b
add branch coverage to pytest
Shotgunosine Feb 9, 2021
9896303
add branch coverage to pytest
Shotgunosine Feb 9, 2021
e82f3cf
Fix coverage omits
Shotgunosine Feb 9, 2021
2fd7a7c
move smoothing out of estimator
Shotgunosine Feb 10, 2021
2a3f88b
stop nesting pytest and coverage
Shotgunosine Feb 10, 2021
b01aa68
add nistats_blurto test to circle
Shotgunosine Feb 10, 2021
04b8157
fix connection when there i no smoothing
Shotgunosine Feb 11, 2021
58ddf5a
fix include nistats_blurto in test data
Shotgunosine Feb 11, 2021
d2878ff
fix coverage
Shotgunosine Feb 11, 2021
dce1184
clean up PEP8 issues
Shotgunosine Feb 12, 2021
7a8cece
clean up duplicated coveragerc file
Shotgunosine Feb 12, 2021
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
116 changes: 58 additions & 58 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -67,30 +67,26 @@ jobs:
path: /tmp/src
- restore_cache:
keys:
- ds003-v0-{{ .Branch }}-
- ds003-v0-master-
- ds003-v0-
- ds003-v1-{{ .Branch }}-
- ds003-v1-master-
- ds003-v1-
- run:
name: Set git ID
command: |
git config --global user.name 'FitLins CircleCI User'
git config --global user.email 'crn.poldracklab@gmail.com'
- run:
name: Install fMRIPrep derivatives of ds000003
name: Install fMRIPrep derivatives of ds000003 and reference data
command: |
datalad install -r ///labs/poldrack/ds003_fmriprep
datalad update ds003_fmriprep/
datalad get ds003_fmriprep/sub-0{1,2,3}/func/*_space-MNI152NLin2009cAsym_desc-*.nii.gz \
ds003_fmriprep/sub-0{1,2,3}/func/*_desc-confounds_*.tsv \
ds003_fmriprep/dataset_description.json \
ds003_fmriprep/sub-*/*/*.json
- run:
name: Download a model for ds000003
command: |
mkdir -p ds003_models
cp /tmp/src/examples/models/ds000003/models/model-001_smdl.json ds003_models/
datalad install -r -s https://gin.g-node.org/shotgunosine/fitlins_tests
datalad update --merge fitlins_tests
datalad get fitlins_tests/ds003/ds003_fmriprep/sub-0{1,2,3}/func/*_space-MNI152NLin2009cAsym_desc-*.nii.gz \
fitlins_tests/ds003/ds003_fmriprep/sub-0{1,2,3}/func/*_desc-confounds_*.tsv \
fitlins_tests/ds003/ds003_fmriprep/dataset_description.json \
fitlins_tests/ds003/ds003_fmriprep/sub-*/*/*.json
datalad get -r fitlins_tests/ds003/nistats_smooth/ fitlins_tests/ds003/afni_smooth/ fitlins_tests/ds003/afni_blurto/ fitlins_tests/ds003/nistats_blurto/
- save_cache:
key: ds003-v0-{{ .Branch }}-{{ .BuildNum }}
key: ds003-v1-{{ .Branch }}-{{ .BuildNum }}
paths:
- /tmp/data

Expand Down Expand Up @@ -153,7 +149,9 @@ jobs:
-e COVERAGE_FILE=/scratch/.coverage.pytest \
--entrypoint="/neurodocker/startup.sh" \
poldracklab/fitlins:latest \
pytest --cov=fitlins --cov-report xml:/scratch/cov_pytest.xml /src/fitlins
pytest --cov=fitlins --cov-report xml:/scratch/cov_pytest.xml \
--cov-config /src/fitlins/docker/multiproc.coveragerc \
--ignore-glob=/src/fitlins/fitlins/tests/* /src/fitlins
- run:
name: Submit pytest coverage
command: |
Expand All @@ -164,7 +162,7 @@ jobs:

test_ds003:
parameters:
estimator:
test_name:
type: string
machine:
image: circleci/classic:201711-01
Expand All @@ -177,9 +175,9 @@ jobs:
- docker-v0-{{ .Branch }}-{{ .Revision }}
- restore_cache:
keys:
- ds003-v0-{{ .Branch }}-
- ds003-v0-master-
- ds003-v0-
- ds003-v1-{{ .Branch }}-
- ds003-v1-master-
- ds003-v1-
- run:
name: Load Docker image layer cache
no_output_timeout: 30m
Expand All @@ -193,40 +191,36 @@ jobs:
fi
- run:
name: Run FitLins
no_output_timeout: 2h
no_output_timeout: 4h
command: |
mkdir -p /tmp/ds003/work /tmp/ds003/derivatives
chmod 777 /tmp/ds003/work /tmp/ds003/derivatives
export CONDA_PREFIX=/opt/miniconda-latest/envs/neuro
docker run --rm -v /tmp/data/ds003_fmriprep:/data:ro \
docker run --rm -v /tmp/data/fitlins_tests:/data:ro \
-v /tmp/ds003/derivatives:/out \
-v /tmp/ds003/work:/scratch \
-v /tmp/data/ds003_models:/models \
-e COVERAGE_FILE=/scratch/.coverage \
-e COVERAGE_FILE=/scratch/.coverage_<< parameters.test_name >> \
--entrypoint="/neurodocker/startup.sh" \
poldracklab/fitlins:latest \
coverage run \
--rcfile /src/fitlins/docker/multiproc.coveragerc \
$CONDA_PREFIX/bin/fitlins /data/sourcedata /out dataset \
-d /data -m /models/model-001_smdl.json -w /scratch \
--participant-label 01 02 03 --space MNI152NLin2009cAsym \
--estimator << parameters.estimator >> \
--n-cpus 2 --mem-gb 4 -vv
pytest --cov=fitlins \
--cov-config /src/fitlins/docker/multiproc.coveragerc \
--cov-report xml:/scratch/.coverage_pytest_<< parameters.test_name >>.xml \
$CONDA_PREFIX/lib/python3.6/site-packages/fitlins/tests \
--fitlins-path=$CONDA_PREFIX/bin/fitlins \
--bids-dir=/data/ds003/ds003_fmriprep/sourcedata \
--output-dir=/out \
--derivatives=/data/ds003/ds003_fmriprep \
--model=/data/ds003/models/model-001_smdl.json \
--work-dir=/scratch \
--test-name=<< parameters.test_name >> \
--database-path=/out/ds003_database \
--reference-dir=/data/ds003
- run:
name: Combine coverage and submit
command: |
# combine coverage
docker run --rm \
-v /tmp/ds003/work:/scratch \
-w /scratch \
--entrypoint="/neurodocker/startup.sh" \
poldracklab/fitlins:latest \
bash -c "coverage combine /scratch/.coverage* \
&& coverage xml"
# submit coverage
bash <(curl --retry 5 -s https://codecov.io/bash) \
-f /tmp/ds003/work/coverage.xml \
-F << parameters.estimator >> \
-f /tmp/ds003/work/.coverage_pytest_<< parameters.test_name >>.xml \
-F << parameters.test_name >> \
-e CIRCLE_JOB
- store_artifacts:
path: /tmp/ds003
Expand All @@ -243,9 +237,9 @@ jobs:
- docker-v0-{{ .Branch }}-{{ .Revision }}
- restore_cache:
keys:
- ds003-v0-{{ .Branch }}-
- ds003-v0-master-
- ds003-v0-
- ds003-v1-{{ .Branch }}-
- ds003-v1-master-
- ds003-v1-
- run:
name: Load Docker image layer cache
no_output_timeout: 30m
Expand All @@ -264,10 +258,10 @@ jobs:
mkdir -p /tmp/ds003/work /tmp/ds003/derivatives
chmod 777 /tmp/ds003/work /tmp/ds003/derivatives
export CONDA_PREFIX=/opt/miniconda-latest/envs/neuro
docker run --rm -v /tmp/data/ds003_fmriprep:/data \
docker run --rm -v /tmp/data/fitlins_tests/ds003/ds003_fmriprep:/data:ro \
-v /tmp/ds003/derivatives:/out \
-v /tmp/ds003/work:/scratch \
-v /tmp/data/ds003_models:/models \
-v /tmp/data/fitlins_tests/ds003/models:/models \
-e COVERAGE_FILE=/scratch/.coverage.database-file-new \
--entrypoint="/neurodocker/startup.sh" \
poldracklab/fitlins:latest \
Expand All @@ -282,10 +276,10 @@ jobs:
no_output_timeout: 2h
command: |
export CONDA_PREFIX=/opt/miniconda-latest/envs/neuro
docker run --rm -v /tmp/data/ds003_fmriprep:/data \
docker run --rm -v /tmp/data/fitlins_tests/ds003/ds003_fmriprep:/data:ro \
-v /tmp/ds003/derivatives:/out \
-v /tmp/ds003/work:/scratch \
-v /tmp/data/ds003_models:/models \
-v /tmp/data/fitlins_tests/ds003/models:/models \
-e COVERAGE_FILE=/scratch/.coverage.database-file-exists \
--entrypoint="/neurodocker/startup.sh" \
poldracklab/fitlins:latest \
Expand Down Expand Up @@ -484,10 +478,10 @@ workflows:
tags:
only: /.*/
- test_ds003:
name: test_ds003_<< matrix.estimator >>
name: test_ds003_<< matrix.test_name >>
matrix:
parameters:
estimator: ["afni", "nistats"]
test_name: ["afni_smooth", "nistats_smooth", "afni_blurto", "nistats_blurto"]
requires:
- build
- cache_test_data
Expand All @@ -506,15 +500,19 @@ workflows:
only: /.*/
- deploy_master:
requires:
- test_ds003_nistats
- test_ds003_afni
- test_ds003_nistats_smooth
- test_ds003_nistats_blurto
- test_ds003_afni_smooth
- test_ds003_afni_blurto
filters:
branches:
only: master
- deploy_docker:
requires:
- test_ds003_nistats
- test_ds003_afni
- test_ds003_nistats_smooth
- test_ds003_nistats_blurto
- test_ds003_afni_smooth
- test_ds003_afni_blurto
- build_docs
filters:
branches:
Expand All @@ -523,8 +521,10 @@ workflows:
only: /.*/
- deploy_pypi:
requires:
- test_ds003_nistats
- test_ds003_afni
- test_ds003_nistats_smooth
- test_ds003_nistats_blurto
- test_ds003_afni_smooth
- test_ds003_afni_blurto
- build_docs
- test_packaging
filters:
Expand Down
20 changes: 12 additions & 8 deletions fitlins/cli/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,10 @@ def get_parser():
"Optional analysis LEVEL (default: l1) may be specified numerically "
"(e.g., `l1`) or by name (`run`, `subject`, `session` or `dataset`). "
"Optional smoothing TYPE (default: iso) must be one of: "
" `iso` (isotropic). e.g., `--smoothing 5:dataset:iso` will perform "
" `iso` (isotropic additive smoothing), `isoblurto` (isotropic "
"smoothing progressivley applied till "
"the target smoothness is reached). "
"e.g., `--smoothing 5:dataset:iso` will perform "
"a 5mm FWHM isotropic smoothing on subject-level maps, "
"before evaluating the dataset level.")

Expand All @@ -137,7 +140,7 @@ def get_parser():
default="nistats", choices=["nistats", "afni"])
g_other.add_argument("--error-ts", action='store_true', default=False,
help='save error time series for first level models.'
' Currently only implemented for afni estimator.')
' Currently only implemented for afni estimator.')

return parser

Expand All @@ -159,7 +162,6 @@ def run_fitlins(argv=None):
# Iterate over empty tuple if undefined
for ign in opts.ignore or ()]


log_level = 25 + 5 * (opts.quiet - opts.verbose)
logger.setLevel(log_level)
nlogging.getLogger('nipype.workflow').setLevel(log_level)
Expand Down Expand Up @@ -201,18 +203,20 @@ def run_fitlins(argv=None):
# TODO - fix neuroscout
derivatives = derivatives[0].split(" ")

if opts.error_ts and opts.estimator != 'afni':
raise NotImplementedError("Saving the error time series is only implmented for"
" the afni estimator. If this is a feature you want"
f" for {opts.estimator} please let us know on github.")
if opts.estimator != 'afni':
if opts.error_ts:
raise NotImplementedError("Saving the error time series is only implmented for"
" the afni estimator. If this is a feature you want"
f" for {opts.estimator} please let us know on github.")

pipeline_name = 'fitlins'
if opts.derivative_label:
pipeline_name += '_' + opts.derivative_label
deriv_dir = op.join(opts.output_dir, pipeline_name)
os.makedirs(deriv_dir, exist_ok=True)
fub.write_derivative_description(
opts.bids_dir, deriv_dir, vars(opts))
opts.bids_dir, deriv_dir, vars(opts)
)

work_dir = mkdtemp() if opts.work_dir is None else opts.work_dir

Expand Down
2 changes: 2 additions & 0 deletions fitlins/interfaces/abstract.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ class FirstLevelEstimatorInputSpec(TraitedSpec):
design_matrix = File(exists=True, mandatory=True)
contrast_info = traits.List(traits.Dict)
smoothing_fwhm = traits.Float(desc='Full-width half max (FWHM) in mm for smoothing in mask')
smoothing_type = traits.Enum('iso', 'isoblurto', desc='Type of smoothing (iso or isoblurto)')


class EstimatorOutputSpec(TraitedSpec):
Expand All @@ -57,6 +58,7 @@ class SecondLevelEstimatorInputSpec(TraitedSpec):
stat_metadata = traits.List(traits.List(traits.Dict), mandatory=True)
contrast_info = traits.List(traits.Dict, mandatory=True)
smoothing_fwhm = traits.Float(desc='Full-width half max (FWHM) in mm for smoothing in mask')
smoothing_type = traits.Enum('iso', 'isoblurto', desc='Type of smoothing (iso or isoblurto)')


class SecondLevelEstimatorOutputSpec(EstimatorOutputSpec):
Expand Down
Loading
0