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

Statistics-Volume pipeline #54

Closed
wants to merge 30 commits into from

Conversation

arnaudmarcoux
Copy link
Contributor

@arnaudmarcoux arnaudmarcoux commented Nov 29, 2019

This PR adds 2 new pipelines : statistics-volume and statistics-volume-correction

  • statistics-volume performs a 2 sample t-test using spm, with covariates indicated in the provided tsv
  • statistics-volume-correction

@alexandreroutier alexandreroutier added enhancement New feature or request pipeline labels Dec 6, 2019
@alexandreroutier alexandreroutier added this to the 0.4.0 milestone Jan 22, 2020
@pep8speaks
Copy link

pep8speaks commented Feb 11, 2020

Hello @arnaudmarcoux! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 42:9: E303 too many blank lines (2)

Line 405:21: W292 no newline at end of file

Line 755:5: E303 too many blank lines (2)
Line 783:1: W293 blank line contains whitespace

Comment last updated at 2020-02-28 15:44:05 UTC

Comment on lines +57 to +55
optional.add_argument("-tup", "--threshold_uncorrected_pvalue",
type=float, default=0.001,
help='Threshold to display the uncorrected p-value '
+ '(--threshold_uncorrected_pvalue 0.001).')

optional.add_argument("-tcp", "--threshold_corrected_pvalue",
type=float, default=0.05,
help='Threshold to display the corrected p-value '
'(default: --threshold_corrected_pvalue 0.05)')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think these flags are either not used or have wrong help message. Is this a copy/paste from statistics-surface?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I do not really know what else to say about them (and yes it is a copy paste :)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok. Simply remove these lines, there is no equivalent in your code.

environment.yml Outdated Show resolved Hide resolved
requirements.txt Outdated Show resolved Hide resolved
@alexandreroutier
Copy link
Contributor

@mdiazmel : In this PR, the clinica/resources/mni_icbm152_t1_tal_nlin_sym_09a.nii.gz will be added. Is this the same template you used in T1Linear pipeline in PR #62?

@arnaudmarcoux: There are several flavours of the ICBM template. Could you tell me why you chose this version compared to another variant? If there is no particular reason, I would be in favor of using the one in T1Linear pipeline.

@@ -68,7 +66,7 @@ class {{ pipeline.class_name }}CLI(ce.CmdParser):
# BIDS and/or CAPS directory as inputs. If the BIDS directory is not needed
# for your pipeline, simply remove:
# bids_directory=self.absolute_path(args.bids_directory),
pipeline = T1FreeSurfer(
pipeline = {{ pipeline.class_name }}(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is currently fixed in PR #63 .

@alexandreroutier
Copy link
Contributor

Hi @arnaudmarcoux,

I finished a first reading of your code. We are quite close to the final version :)

I noticed that instanciation tests are missing. Moreover, I would advice you to move the content of statistics_volume_correction folder to statistics_volume folder. I thinks this make sense since explanations on the statistics-volume / statistics-volume-correction pipelines will be on the same Wiki page.

Btw, it seems that outputs are not temporarly saved in working directory. Coud you tell me if this is the case or not?

I will do the feedback regarding the Wiki tomorrow.

Alex

@alexandreroutier
Copy link
Contributor

Currently, the output console looks like:

No info on how much size the pipeline takes. Running anyway...
USING CLASSICAL SPM
USING CLASSICAL SPM
USING CLASSICAL SPM
USING CLASSICAL SPM
USING CLASSICAL SPM
[11:59:36] The statistics-volume pipeline has completed. You can now delete the working directory (/home/alexandre.routier/Temp/StatisticsVolume/in/WD/statistics-volume).

The first line will disappear when info.json will be updated. You should remove or comment the cprint instructions regarding the use of SPM / SPM-Standalone.

In build_input_node() method, you should add something like this:

if len(self.subjects):
    print_images_to_process(self.subjects, self.sessions)
    cprint('The pipeline will last a few minutes. Images generated by SPM will popup during the pipeline.')
    print_begin_image('group-' + self.parameters['group_id'])

(Adapted from t1-create-dartel pipeline)

@arnaudmarcoux
Copy link
Contributor Author

The first line will disappear when info.json will be updated.

Indeed, pipeline disk usage is determined by:
( number or subjects in the analysis) X space_caps and ( number or subjects in the analysis) X space_wd. In this case, disk usage forthis pipeline is always the same and is not dependant on the number of subjects. We cannot use the current system.

You should remove or comment the cprint instructions regarding the use of SPM / SPM-Standalone.

Done

In build_input_node() method, you should add something like this:

if len(self.subjects):
    print_images_to_process(self.subjects, self.sessions)
    cprint('The pipeline will last a few minutes. Images generated by SPM will popup during the pipeline.')
    print_begin_image('group-' + self.parameters['group_id'])

Done

Btw, it seems that outputs are not temporarly saved in working directory. Coud you tell me if this is the case or not?

Everything is working on working dirs, except last node of statistics-volume-correction. I did not have a simple method to save the outputs, so I did not use a datasink. That's why there is no output node.

)
pipeline.run(plugin='MultiProc', plugin_args={'n_procs': 4}, bypass_check=True)
compare_folders(join(root, 'out'), join(root, 'ref'), 'caps')

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing:

    # Remove data in out folder
    clean_folder(join(root, 'out', 'caps'), recreate=False)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

Comment on lines +742 to +744
assert np.allclose(nib.load(output_t_stat).get_data(),
nib.load(ref_t_stat).get_data())

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing:

    # Remove data in out folder
    clean_folder(join(root, 'out', 'caps'), recreate=False)

?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes

@alexandreroutier
Copy link
Contributor

When running statistics-volume pipeline, I have the following files;

└── group-GroupTest
    └── statistics_volume
        └── group_comparison_measure-fdg
            ├── group-GroupTest_report-1.png
            ├── group-GroupTest_report-2.png
            ├── group-GroupTest_report-3.png
            ├── group-GroupTest_report-4.png
            ├── group-GroupTest_report-5.png

Why do we have 5 *report.png files ? We should only have 2: group-GroupTest_AD-lt-CN_measure-fdg_fwhm-8_report.png and group-GroupTest_CN-lt-AD_measure-fdg_fwhm-8_report.png containing results of SPM at cluster_threshold of 0.001.

Besides, I made some mistakes when specifying the CAPS:

└── group-GroupTest
    └── statistics_volume
        └── group_comparison_measure-fdg
            ├── group-GroupTest_contrast-group_mask.nii
            ├── group-GroupTest_contrast-group_RPV.nii

_contrast-group should not exist thus giving the final files group-GroupTest_mask.nii and group-GroupTest_RPV.nii.

Finally:

└── group-GroupTest
    └── statistics_volume
        └── group_comparison_measure-fdg
            ├── group-GroupTest_contrast-group_measure-AD_fwhm-8_regressionCoefficient.nii
            ├── group-GroupTest_contrast-group_measure-age_fwhm-8_regressionCoefficient.nii
            ├── group-GroupTest_contrast-group_measure-CN_fwhm-8_regressionCoefficient.nii
            ├── group-GroupTest_contrast-group_measure-sex_fwhm-8_regressionCoefficient.nii

It should be _measure-fdg in all cases. When I put contrast-<contrast> at the beginning, I was thinking of contrast-age or contrast-sex for instance. In hindsight, I would suggest instead covariate-age giving the final files:

└── group-GroupTest
    └── statistics_volume
        └── group_comparison_measure-fdg
            ├── group-GroupTest_covariate-AD_measure-fdg_fwhm-8_regressionCoefficient.nii
            ├── group-GroupTest_covariate-age_measure-fdg_fwhm-8_regressionCoefficient.nii
            ├── group-GroupTest_covariate-CN_measure-fdg_fwhm-8_regressionCoefficient.nii
            ├── group-GroupTest_covariate-sex_measure-fdg_fwhm-8_regressionCoefficient.nii

Open question:

  • In t1-volume / pet-volume pipelines, smoothing values are reported like _fwhm-8mm whereas pet-surface / statistics-surface report smoothing like  _fwhm-10. In this pipeline,  _fwhm-8 convention is used. Do we keep it? 

@alexandreroutier
Copy link
Contributor

Final request: can you move the content of statistics_volume_correction into statistics_volume ?

@alexandreroutier
Copy link
Contributor

The first line will disappear when info.json will be updated.

Indeed, pipeline disk usage is determined by:
( number or subjects in the analysis) X space_caps and ( number or subjects in the analysis) X space_wd. In this case, disk usage forthis pipeline is always the same and is not dependant on the number of subjects. We cannot use the current system.

Space estimation was given in t1-volume-create-dartel even though it is a groupe pipeline. Do you you remember how the values were set? In order to apply the same rationale for your pipeline.

@arnaudmarcoux arnaudmarcoux marked this pull request as ready for review February 28, 2020 14:02
@arnaudmarcoux arnaudmarcoux changed the title [WIP] Statistics-Volume pipeline Statistics-Volume pipeline Feb 28, 2020
@arnaudmarcoux
Copy link
Contributor Author

Space estimation was given in t1-volume-create-dartel even though it is a groupe pipeline. Do you you remember how the values were set? In order to apply the same rationale for your pipeline

I don't remember how this was set...

Why do we have 5 *report.png files ?

2 different contrasts group 1 > group 2 and group 2 > group 1
And for each (SPM settings) : 1) p=0.05 FWE (that is traditional use of SPM) and 2) p=0.001 uncorrected

Which makes 4 reports (5 because one of them is more than 1-page long. Moreover It is not possible to link each report to its task.

_contrast-group should not exist thus giving the final files group-GroupTest_mask.nii and group-GroupTest_RPV.nii.

Done

In t1-volume / pet-volume pipelines, smoothing values are reported like _fwhm-8mm whereas pet-surface / statistics-surface report smoothing like _fwhm-10. In this pipeline, _fwhm-8 convention is used. Do we keep it?

I dont really have an opinion

@arnaudmarcoux
Copy link
Contributor Author

Also, I did this image a while ago, if you want to use it in the wiki to indicate where to look for statistics-volume-correction. All the items marked are necessary to determine what to indicate in the command line interface.
Instructions_for_corrections

@alexandreroutier
Copy link
Contributor

I don't remember how this was set...

Ok. We'll put that aside.

2 different contrasts group 1 > group 2 and group 2 > group 1
And for each (SPM settings) : 1) p=0.05 FWE (that is traditional use of SPM) and 2) p=0.001 uncorrected

Which makes 4 reports (5 because one of them is more than 1-page long. Moreover It is not possible to link each report to its task.

Ok. Since FWEp is performed in statistics-volume-correction, it would be simpler to remove reports regarding FWEp. What do you think?

@alexandreroutier
Copy link
Contributor

Also, I did this image a while ago, if you want to use it in the wiki to indicate where to look for statistics-volume-correction. All the items marked are necessary to determine what to indicate in the command line interface.
Instructions_for_corrections

Thanks! I put a report in the Wiki but it didn't have annotations.

@alexandreroutier
Copy link
Contributor

To be followed in PR #67.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request pipeline
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants