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

Deconvolving HRF step takes a huge amount of time #51

Closed
lrq3000 opened this issue Dec 2, 2018 · 11 comments
Closed

Deconvolving HRF step takes a huge amount of time #51

lrq3000 opened this issue Dec 2, 2018 · 11 comments

Comments

@lrq3000
Copy link

lrq3000 commented Dec 2, 2018

The HRF estimation seems to be quite fast (particularly with microtime resolution 1 and AR off), but the "deconvolving HRF" step always takes very very long, even for just 300 volumes.

Is there a way to make this step faster?

@danielemarinazzo
Copy link
Collaborator

danielemarinazzo commented Dec 2, 2018 via email

@danielemarinazzo
Copy link
Collaborator

Something else came to our minds, it might be that you do not use a mask, and then remove the outliers and replace these missing values (including a huge number of voxels outside the brain).
this step can take very very long, and it's useless.

@lrq3000
Copy link
Author

lrq3000 commented Dec 4, 2018

Dear Daniele,

Thank you very much for your fast replies and also for your email! I take this opportunity to link to the solution to combine CONN and rshrf.

About the time it takes, I reworked further my pipeline to generate additional info that might be useful to you. Here is the log I get:

> -------------------------
> === HEMODYNAMIC RESPONSE FUNCTION USING RSHRF TOOLBOX ===
> 
> ---- PROCESSING CONDITION ket SUBJECT 1 (ana_5896) SESSION S2 ----
> 
> 
> ------------------------------------------------------------------------
> Running job #1
> ------------------------------------------------------------------------
> Running 'Voxel-wise HRF deconvolution'
> Reading NIFTI Data ...
> # 1739757 voxels inside defaut mask ...
> Reading Covariates ...
> Removing regressors & Detrend................. 
>  Frequency filter.................... 
>  #1739757 
> Starting parallel pool (parpool) using the 'local' profile ...
> connected to 6 workers.
> ...................................................................................................................................................................................................................................................
> Done HRF estimation   195.60 seconds
> Deconvolving HRF ...
> Elapsed time is 254.491797 seconds.
> Save HRF deconvolution results....
> height outlier: negative/zeros #243 + extreme #16801, [263.080 1315.501];
> Done    'Voxel-wise HRF deconvolution'
> Done
> 
> ---- PROCESSING CONDITION ket SUBJECT 1 (ana_5896) SESSION W1 ----
> 
> 
> ------------------------------------------------------------------------
> Running job #1
> ------------------------------------------------------------------------
> Running 'Voxel-wise HRF deconvolution'
> Reading NIFTI Data ...
> # 1658904 voxels inside defaut mask ...
> Reading Covariates ...
> Removing regressors & Detrend................. 
>  Frequency filter.................... 
>  #1658904 
> Starting parallel pool (parpool) using the 'local' profile ...
> connected to 6 workers.
> ...............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
> Done HRF estimation   185.79 seconds
> Deconvolving HRF ...
> Elapsed time is 88.535682 seconds.
> Save HRF deconvolution results....
> height outlier: negative/zeros #6353 + extreme #27171, [151.461 1348.671];
> Done    'Voxel-wise HRF deconvolution'
> Done
> 
> ---- PROCESSING CONDITION ket SUBJECT 2 (ana_5913) SESSION S2 ----
> 
> 
> ------------------------------------------------------------------------
> Running job #1
> ------------------------------------------------------------------------
> Running 'Voxel-wise HRF deconvolution'
> Reading NIFTI Data ...
> # 1473874 voxels inside defaut mask ...
> Reading Covariates ...
> Removing regressors & Detrend................. 
>  Frequency filter.................... 
>  #1473874 
> Starting parallel pool (parpool) using the 'local' profile ...
> connected to 6 workers.
> ............................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................
> Done HRF estimation   163.17 seconds
> Deconvolving HRF ...
> Elapsed time is 5416.796399 seconds.
> Save HRF deconvolution results....
> height outlier: negative/zeros #3459 + extreme #13968, [180.705 1833.208];
> Done    'Voxel-wise HRF deconvolution'
> Done
> 
> ---- PROCESSING CONDITION ket SUBJECT 2 (ana_5913) SESSION W1 ----
> 
> 
> ------------------------------------------------------------------------
> Running job #1
> ------------------------------------------------------------------------
> Running 'Voxel-wise HRF deconvolution'
> Reading NIFTI Data ...
> # 1431272 voxels inside defaut mask ...
> Reading Covariates ...
> Removing regressors & Detrend................. 
>  Frequency filter.................... 
>  #1431272 
> Starting parallel pool (parpool) using the 'local' profile ...
> connected to 6 workers.
> ...............................................................
> Done HRF estimation   142.70 seconds
> Deconvolving HRF ...
> Elapsed time is 22804.829655 seconds.
> Save HRF deconvolution results....
> height outlier: negative/zeros #63 + extreme #18985, [53.059 1353.533];
> Done    'Voxel-wise HRF deconvolution'
> Done
> 
> ---- PROCESSING CONDITION ket SUBJECT 3 (ana_5925) SESSION S2 ----
> 
> 
> ------------------------------------------------------------------------
> Running job #1
> ------------------------------------------------------------------------
> Running 'Voxel-wise HRF deconvolution'
> Reading NIFTI Data ...
> # 1578974 voxels inside defaut mask ...
> Reading Covariates ...
> Removing regressors & Detrend................. 
>  Frequency filter.................... 
>  #1578974 
> Starting parallel pool (parpool) using the 'local' profile ...
> connected to 6 workers.
> ............
> Done HRF estimation   101.43 seconds
> Deconvolving HRF ...

This is a post-processing on 9 subjects with 2 sessions (S2 and W1) for each. As you can see, the first deconvolution is quite quick, then for each session it becomes longer and longer, approximately 10x more time for each. I tried several times, modifying some parameters until I came back to near the default settings in rshrf, and it still happens the same, I never went beyond subject 3 session S2 (first session), because if the exponential increase is true, it would approximately take 50hours to complete (currently it's been running since 30 hours to no avail).

More precisely, here are the deconvolution runtimes so far from the log: 254s, 88s, 5416s, 22804s.

Your hypothesis that I don't use a mask is correct, but can this explain why the time is increasing between sessions? If it's because of the mask, I would expect the time increase to be constant for the same number of volumes and voxel resolution, which hold for my dataset.

I attach the jobs that my script is dynamically generating, maybe you can find more info from this? jobs.zip

I can also make available anything else if it can help, just let me know.

Thank you very much for taking the time to help me on this!

@danielemarinazzo
Copy link
Collaborator

Dear Stephan

thanks a lot for the update on the interface with CONN, I'm sure it will be useful to others.

The info that you provided indeed allows to understand that the issue is in the deconvolution phase.

We will look into the jobs.

For the moment, can you just try to run one subject/session per time, or change the order? Just to see if there is actually an increasing/accumulating delay (as it seems), or if some subjects/sessions are problematic.

@lrq3000
Copy link
Author

lrq3000 commented Dec 4, 2018

Thank you Daniele for this great idea, I'm running now the pipeline by beginning with the 3rd subject, so far it still did not finish, so it seems something in the data is making rshrf deconvolution go wild.

I let it run for the night to make sure and if it did not finish, tomorrow I can send you an excerpt of the dataset if you agree.

@lrq3000
Copy link
Author

lrq3000 commented Dec 4, 2018

BTW my pipeline is here: https://github.com/lrq3000/csg_mri_pipelines/blob/master/preprocessing/fmri/script_preproc_fmri_csg.m#L571

It's temporary as I will change it to process after CONN (currently it's done just before, which is wrong), but the rshrf parameters won't change.

@guorongwu
Copy link
Collaborator

guorongwu commented Dec 5, 2018 via email

@lrq3000
Copy link
Author

lrq3000 commented Dec 5, 2018

@guorongwu Thank you very much! Adding the mask indeed solved the issue (rmoutlier can be set to 1).

May I suggest to add this template as the default value in the rshrf batch?

I thought that rmoutlier was necessary, what would you guys advise for a typical resting state functional connectivity analysis? And what about AR correction?

Thank you very much!
Best regards

@guorongwu
Copy link
Collaborator

guorongwu commented Dec 6, 2018 via email

@lrq3000
Copy link
Author

lrq3000 commented Dec 7, 2018

Thank you very much @guorongwu for the info!

I am not sure I understand about the remove outlier option, if I enabled it (inpainting outliers with NaN) this can change the final deconvolved signal (or is it the other way around?).

For the default template, yes my pipeline is using MNI space, but since most SPM based pipelines do the same I think it would really ease newcomers to get a hang of the rshrf toolbox if this template was provided as the default, or if not, at least in the help message?

I have a final but very crucial question: can the rshrf toolbox work on smoothed data? Because the way CONN author advised to combine CONN + rshrf is to use rshrf after CONN denoising, which is done on smoothed data. If rshrf cannot work on smoothed data, would it be possible/mathematically meaningful to do the hrf deconvolution calculation on non-smoothed data, save it and apply it later on the smoothed data? What I have in mind is something like a normalization/DARTEL transform?

@guorongwu
Copy link
Collaborator

guorongwu commented Dec 9, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants