neurospin / pypreprocess

Preprocessing scripts for neuro imaging
105 stars 66 forks source link

Several examples fail because of glm reporter wrong input #318

Open thomasbazeille opened 5 years ago

thomasbazeille commented 5 years ago

The code is simple :

sd = fetch_spm_multimodal_fmri()
sd.output_dir = "/tmp/sub001"
sd.func = [sd.func1, sd.func2]

do_subject_preproc(sd.__dict__, concat=False, coregister=True, stc=True,
                   tsdiffana=True, realign=True, report=True, reslice=True)

But for some reason sd is of the wrong type :

Full Stack Trace:
Traceback (most recent call last):
  File "examples/pure_python/pure_python_preproc_demo.py", line 16, in <module>
    tsdiffana=True, realign=True, report=True, reslice=True)
  File "/home/parietal/tbazeill/pypreprocess/build/py3k/pypreprocess/purepython_preproc_utils.py", line 282, in do_subject_preproc
    n_sessions = len(subject_data.session_ids)
TypeError: object of type 'NoneType' has no len()

More generally, @kchawla-pi is working on cleaning the glm reporter code for nistats especially the types of input needed. Maybe we should wait until he's finished and build on that

thomasbazeille commented 5 years ago

Another bug related to glm reporter plagues the examples running :

from pypreprocess.reporting.glm_reporter import generate_subject_stats_report

generate_subject_stats_report(
    stats_report_filename,
    contrasts,
    z_maps,
    fmri_glm.masker_.mask_img_,
    design_matrices=[design_matrix],
    subject_id=subject_data.subject_id,
    anat=anat_img,
    display_mode='ortho',
    threshold=3.,
    cluster_th=50,  # 'large' clusters
    start_time=stats_start_time,
    paradigm=paradigm,
    TR=tr,
    nscans=nscans,
    hfcut=hfcut,
    frametimes=frametimes,
    drift_model=drift_model,
    hrf_model=hrf_model)

such as easy_start/easy_start/nipype_preproc_spm_auditory.py ; pipelining/nipype_preproc_spm_multimodal_faces.py or pipelining/nistats_glm_fsl_feeds_fmri.py.

It apparently comes from contrasts/zmaps/design_matrixes input format that has to be carefully chosen, as in : https://github.com/kchawla-pi/nistats/blob/glm-reporter-attempt2/examples/06_glm_reporter/02_first_level_models/report_fiac_analysis.py

A Traceback (most recent call last):
  File "examples/easy_start/nipype_preproc_spm_auditory.py", line 142, in <module>
    hrf_model=hrf_model)
  File "/home/parietal/tbazeill/pypreprocess/build/py3k/pypreprocess/reporting/glm_reporter.py", line 358, in generate_subject_stats_report
    z_threshold=threshold, title=title)
  File "/home/parietal/tbazeill/pypreprocess/build/py3k/pypreprocess/reporting/glm_reporter.py", line 86, in generate_level1_stats_table
    clusters = [c for c in clusters if c['cluster_p_value'] < cluster_pval]
  File "/home/parietal/tbazeill/pypreprocess/build/py3k/pypreprocess/reporting/glm_reporter.py", line 86, in <listcomp>
    clusters = [c for c in clusters if c['cluster_p_value'] < cluster_pval]
TypeError: '<' not supported between instances of 'NoneType' and 'float'
thomasbazeille commented 5 years ago

Related to #287