Charestlab / pyGLMdenoise

python implementation of GLMdenoise
6 stars 6 forks source link

Store outputs as files and fix bids #36

Closed JasperVanDenBosch closed 5 years ago

JasperVanDenBosch commented 5 years ago
JasperVanDenBosch commented 5 years ago
In [1]: %run example_haxby_2001.py                                                                                                            
found data.
No preprocessed runs found for subject 1 task objectviewing session None
No preprocessed runs found for subject 2 task objectviewing session None
No preprocessed runs found for subject 3 task objectviewing session None
Removing event file for which no bold file was found
Removing event file for which no bold file was found
['/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-02_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-03_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-04_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-05_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-07_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-08_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-09_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-10_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-11_bold_space-MNI152NLin2009cAsym_preproc.nii.gz',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/derivatives/fmriprep/sub-4/func/sub-4_task-objectviewing_run-12_bold_space-MNI152NLin2009cAsym_preproc.nii.gz']
['/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-02_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-03_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-04_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-05_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-06_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-08_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-09_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-10_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-11_events.tsv',
 '/home/jasper/Projects/pyGLMdenoise/data/ds000105/sub-4/func/sub-4_task-objectviewing_run-12_events.tsv']
Optimising HRF...
     optimising hrf :1
JasperVanDenBosch commented 5 years ago
Global HRF estimate is far from the initial seed,probably indicating low SNR.  We are just going touse the initial seed as the HRF estimate.

Making initial fit
Cross-validating run:   0%|                                                                                            | 0/10 [00:00<?, ?it/s]
---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
~/Projects/pyGLMdenoise/example_haxby_2001.py in <module>
     40 ## run pyGLMdenoise on our BIDS dataset:
     41 from glmdenoise import run_bids_directory
---> 42 run_bids_directory(dataset_dir)

~/Projects/pyGLMdenoise/glmdenoise/io/directory.py in run_bids_directory(directory, sub_num, sub, task)
     20 
     21     bids = BidsDirectory(directory)
---> 22     return run_bids(bids, sub_num=sub_num, sub=sub, task=task)
     23 
     24 

~/Projects/pyGLMdenoise/glmdenoise/io/directory.py in run_bids(bids, sub_num, sub, task, ses)
     61         subs = bids.get_preprocessed_subjects_ids()
     62         for sub in subs:
---> 63             run_bids(bids, sub=sub)
     64 
     65 def run_bids_subset(bids, sub, task, ses=None):

~/Projects/pyGLMdenoise/glmdenoise/io/directory.py in run_bids(bids, sub_num, sub, task, ses)
     53         tasks = bids.get_tasks_for_subject(sub)
     54         for task in tasks:
---> 55             run_bids(bids, sub=sub, task=task)
     56     elif sub_num:
     57         sub = bids.subject_id_from_number(sub_num)

~/Projects/pyGLMdenoise/glmdenoise/io/directory.py in run_bids(bids, sub_num, sub, task, ses)
     49             run_bids(bids, sub=sub, task=task, ses=ses)
     50         if sessions == []:
---> 51             run_bids_subset(bids, sub, task)
     52     elif sub:
     53         tasks = bids.get_tasks_for_subject(sub)

~/Projects/pyGLMdenoise/glmdenoise/io/directory.py in run_bids_subset(bids, sub, task, ses)
     94     out = Output()
     95     out.fit_bids_context(bids, sub=sub, task=task, ses=ses)
---> 96     return run_files(bold_files, event_files, tr=trs[0], out=out)

~/Projects/pyGLMdenoise/glmdenoise/io/files.py in run_files(bold_files, event_files, tr, out)
     24     design = [pandas.read_csv(f, delimiter='\t') for f in event_files]
     25     gd = GLMdenoise(design, data, tr)
---> 26     gd.fit()
     27     gd.plot_figures(out.create_report())
     28     for image_name in ['pseudo_t_stats']:

~/Projects/pyGLMdenoise/glmdenoise/pyGlmdenoise.py in fit(self)
    260             self.hrfparams["hrffitvoxels"] = None
    261 
--> 262         print('Making initial fit')
    263         r2s_initial = cross_validate(
    264             self.data, self.design, self.extra_regressors, poly_degs=self.poly_degs)[0]

~/Projects/pyGLMdenoise/glmdenoise/pyGlmdenoise.py in cross_validate(data, design, extra_regressors, poly_degs)
    126         mask = np.arange(n_runs) != run
    127 
--> 128         betas.append(fit_runs(
    129             list(compress(whitened_data, mask)),
    130             list(compress(whitened_design, mask))))

NameError: global name 'start_coldefault_params' is not defined
> /home/jasper/Projects/pyGLMdenoise/glmdenoise/pyGlmdenoise.py(128)cross_validate()
    126         mask = np.arange(n_runs) != run
    127 
--> 128         betas.append(fit_runs(
    129             list(compress(whitened_data, mask)),
    130             list(compress(whitened_design, mask))))