8000 IndexError: list index out of range · Issue #5 · ln2t/cvrmap · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

IndexError: list index out of range #5

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

Closed
JiyangJiang opened this issue Dec 2, 2024 · 7 comments
Closed

IndexError: list index out of range #5

JiyangJiang opened this issue Dec 2, 2024 · 7 comments

Comments

@JiyangJiang
Copy link
JiyangJiang commented Dec 2, 2024

Dear CVRmap developers,

We collected some CO2-challenged BOLD images for CVR, and processed them with FMRIPrep with --use-aroma. When trying to run CVRmap, the following error was encountered.

fmriprep_output_dir=${BIDS_dir}/derivatives/fmriprep_${fmriprep_version}
cvrmap_version=2.0.25

singularity run --cleanenv \
                 -B ${BIDS_dir}:/rawdata \
                 -B ${BIDS_dir}/derivatives:/derivatives \
                 -B ${fmriprep_output_dir}:/fmriprep_output \
                 /path/to/cvrmap.sif \
                 /rawdata \
                 /derivatives/cvrmap-${cvrmap_version} \
                 --participant_label ${subject_ID} \
                 --skip_bids_validator \
                 --fmriprep_dir /fmriprep_output \
                 --task co2 \
                 participant

INFO (2024-12-03-08-32-56) Version: 2.0.25
INFO (2024-12-03-08-32-56) Indexing BIDS dataset...
INFO (2024-12-03-08-32-58) Defaulting to space MNI152NLin2009cAsym
INFO (2024-12-03-08-32-58) Bids directory: /rawdata
INFO (2024-12-03-08-32-58) Fmriprep directory: /fmriprep_output
INFO (2024-12-03-08-32-58) Subject(s) to analyse: ['vci016']
INFO (2024-12-03-08-32-58) Task to analyse: co2
INFO (2024-12-03-08-32-58) Selected space: MNI152NLin2009cAsym
INFO (2024-12-03-08-32-58) Running for participant vci016
Traceback (most recent call last):
  File "/usr/local/bin/cvrmap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/cvrmap.py", line 69, in main
    preproc, mni_preproc = get_preproc(basic_filter, layout)
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/io_tools.py", line 552, in get_preproc
    preproc.bids_load(layout, _basic_filter, 'bold')
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/processing.py", line 59, in bids_load
    json_path = layout.get(**filters, extension='json')[0]
                ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

I wonder if you have any suggestions or insights on this?

Many thanks,
Jiyang

@arovai
Copy link
Contributor
arovai commented Dec 3, 2024

Hello!
It seems CVRmap is struggling to find the JSON file of the preprocessed data.
Please make sure that subject vci016 has been correctly preprocessed, with task co2 and space MNI152NLin2009cAsym.
If you can provide the output of
ls ${fmriprep_output_dir}/sub-vci016/func
that could also be helpful to check that the expected JSON file is in there along with other preprocessed data.
Let me know how it goes!

@JiyangJiang
Copy link
Author

Hi arovai,

Thanks for your reply. It seems no error is found in FMRIPrep html report. I listed the files in fmriprep_output_dir/sub-vci016/func folder below:

$ tree sub-vci016/func/                                         
sub-vci016/func/                                                                                                                     
├── sub-vci016_task-co2_dir-PA_AROMAnoiseICs.csv                                                                                     
├── sub-vci016_task-co2_dir-PA_boldref.nii.gz                                                                                        
├── sub-vci016_task-co2_dir-PA_desc-brain_mask.json                                                                                  
├── sub-vci016_task-co2_dir-PA_desc-brain_mask.nii.gz                                                                                
├── sub-vci016_task-co2_dir-PA_desc-confounds_timeseries.json                                                                        
├── sub-vci016_task-co2_dir-PA_desc-confounds_timeseries.tsv                                                                         
├── sub-vci016_task-co2_dir-PA_desc-MELODIC_mixing.tsv                                                                               
├── sub-vci016_task-co2_dir-PA_desc-preproc_bold.json                                                                                
├── sub-vci016_task-co2_dir-PA_desc-preproc_bold.nii.gz                                                                              
├── sub-vci016_task-co2_dir-PA_from-scanner_to-boldref_mode-image_xfm.txt                                                            
├── sub-vci016_task-co2_dir-PA_from-scanner_to-T1w_mode-image_xfm.txt                                                                
├── sub-vci016_task-co2_dir-PA_from-T1w_to-scanner_mode-image_xfm.txt                                                                
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_boldref.json                                                          
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_boldref.nii.gz                                                        
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aparcaseg_dseg.json                                              
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aparcaseg_dseg.nii.gz                                            
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aseg_dseg.json                                                   
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aseg_dseg.nii.gz                                                 
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.json
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.json
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.json
├── sub-vci016_task-co2_dir-PA_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii.gz
├── sub-vci016_task-co2_dir-PA_space-T1w_boldref.nii.gz
├── sub-vci016_task-co2_dir-PA_space-T1w_desc-aparcaseg_dseg.nii.gz
├── sub-vci016_task-co2_dir-PA_space-T1w_desc-aseg_dseg.nii.gz
├── sub-vci016_task-co2_dir-PA_space-T1w_desc-brain_mask.json
├── sub-vci016_task-co2_dir-PA_space-T1w_desc-brain_mask.nii.gz
├── sub-vci016_task-co2_dir-PA_space-T1w_desc-preproc_bold.json
├── sub-vci016_task-co2_dir-PA_space-T1w_desc-preproc_bold.nii.gz
├── sub-vci016_task-rest_dir-PA_AROMAnoiseICs.csv
├── sub-vci016_task-rest_dir-PA_boldref.nii.gz
├── sub-vci016_task-rest_dir-PA_desc-brain_mask.json
├── sub-vci016_task-rest_dir-PA_desc-brain_mask.nii.gz
├── sub-vci016_task-rest_dir-PA_desc-confounds_timeseries.json
├── sub-vci016_task-rest_dir-PA_desc-confounds_timeseries.tsv
├── sub-vci016_task-rest_dir-PA_desc-MELODIC_mixing.tsv
├── sub-vci016_task-rest_dir-PA_desc-preproc_bold.json
├── sub-vci016_task-rest_dir-PA_desc-preproc_bold.nii.gz
├── sub-vci016_task-rest_dir-PA_from-scanner_to-boldref_mode-image_xfm.txt
├── sub-vci016_task-rest_dir-PA_from-scanner_to-T1w_mode-image_xfm.txt
├── sub-vci016_task-rest_dir-PA_from-T1w_to-scanner_mode-image_xfm.txt
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_boldref.json
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_boldref.nii.gz
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aparcaseg_dseg.json
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aparcaseg_dseg.nii.gz
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aseg_dseg.json
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-aseg_dseg.nii.gz
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.json
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-brain_mask.nii.gz
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.json
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.json
├── sub-vci016_task-rest_dir-PA_space-MNI152NLin6Asym_desc-smoothAROMAnonaggr_bold.nii.gz
├── sub-vci016_task-rest_dir-PA_space-T1w_boldref.nii.gz
├── sub-vci016_task-rest_dir-PA_space-T1w_desc-aparcaseg_dseg.nii.gz
├── sub-vci016_task-rest_dir-PA_space-T1w_desc-aseg_dseg.nii.gz
├── sub-vci016_task-rest_dir-PA_space-T1w_desc-brain_mask.json
├── sub-vci016_task-rest_dir-PA_space-T1w_desc-brain_mask.nii.gz
├── sub-vci016_task-rest_dir-PA_space-T1w_desc-preproc_bold.json
└── sub-vci016_task-rest_dir-PA_space-T1w_desc-preproc_bold.nii.gz

0 directories, 62 files

We have two tasks, co2 and rest.

Thanks,
Jiyang

@arovai
Copy link
Contributor
arovai commented Dec 5, 2024

One reason I can see is that you have an explicit resolution entity in your fmriprep output, but this is not guessed by CVRmap. Since it is not explicitly specified in the command line call, it assumes there is no resolution entity and cannot find the preprocessed data.
Please try to relaunch CVRmap with the following option:

--space MNI152NLin2009cAsym:res-2

and let me know how it goes!
Best
Antonin

@JiyangJiang
Copy link
Author

It seems the problem persisted after adding --space MNI152NLin2009cAsym:res-2:

singularity run --cleanenv \
                -B ${BIDS_dir}:/rawdata \
                -B ${BIDS_dir}/derivatives:/derivatives \
                -B ${fmriprep_output_dir}:/fmriprep_output \
                $BMP_3RD_PATH/cvrmap-${cvrmap_version}.sif \
                /rawdata \
                /derivatives/cvrmap-${cvrmap_version} \
                --participant_label ${subject_ID} \
                --skip_bids_validator \
                --fmriprep_dir /fmriprep_output \
                --task co2 \
                --space MNI152NLin2009cAsym:res-2 \
                participant

INFO (2024-12-09-08-11-54) Version: 2.0.25
INFO (2024-12-09-08-11-54) Indexing BIDS dataset...
INFO (2024-12-09-08-11-56) Bids directory: /rawdata
INFO (2024-12-09-08-11-56) Fmriprep directory: /fmriprep_output
INFO (2024-12-09-08-11-56) Subject(s) to analyse: ['vci016']
INFO (2024-12-09-08-11-56) Task to analyse: co2
INFO (2024-12-09-08-11-56) Selected space: MNI152NLin2009cAsym
INFO (2024-12-09-08-11-56) Selected resolution: 2
INFO (2024-12-09-08-11-56) Running for participant vci016
Traceback (most recent call last):
  File "/usr/local/bin/cvrmap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/cvrmap.py", line 72, in main
    melodic_mixing_df, melodic_mixing_path = get_melodic_mixing(basic_filter, layout)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/io_tools.py", line 467, in get_melodic_mixing
    melodic_mixing = layout.get(**_bids_filter)[0]
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range


@JiyangJiang
Copy link
Author

I reran FMRIPrep without specifying res2 for MNI152NLin2009cAsym. CVRmap gives a different error:

singularity run --cleanenv \
                -B ${BIDS_dir}:/rawdata \
                -B ${BIDS_dir}/derivatives:/derivatives \
                -B ${fmriprep_output_dir}:/fmriprep_output \
                $BMP_3RD_PATH/cvrmap-${cvrmap_version}.sif \
                /rawdata \
                /derivatives/cvrmap-${cvrmap_version} \
                --participant_label ${subject_ID} \
                --skip_bids_validator \
                --fmriprep_dir /fmriprep_output \
                --task co2 \
                --space MNI152NLin2009cAsym \
                participant

INFO (2024-12-09-10-05-22) Version: 2.0.25
INFO (2024-12-09-10-05-22) Indexing BIDS dataset...
INFO (2024-12-09-10-05-24) Bids directory: /rawdata
INFO (2024-12-09-10-05-24) Fmriprep directory: /fmriprep_output
INFO (2024-12-09-10-05-24) Subject(s) to analyse: ['vci016']
INFO (2024-12-09-10-05-24) Task to analyse: co2
INFO (2024-12-09-10-05-24) Selected space: MNI152NLin2009cAsym
INFO (2024-12-09-10-05-24) Running for participant vci016
Traceback (most recent call last):
  File "/usr/local/bin/cvrmap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/cvrmap.py", line 90, in main
    physio = get_physio_data(basic_filter, layout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/io_tools.py", line 427, in get_physio_data
    physio.bids_load(layout, physio_filter, 'timecourse', **{'col': 1})
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/processing.py", line 64, in bids_load
    data = numpy.loadtxt(data_path, usecols=kwargs['col'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1356, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/numpy/lib/npyio.py", line 999, in _read
    arr = _load_from_filelike(
          ^^^^^^^^^^^^^^^^^^^^
ValueError: invalid column index 1 at row 1 with 1 columns

@arovai
Copy link
Contributor
arovai commented Dec 10, 2024

It seems the problem persisted after adding --space MNI152NLin2009cAsym:res-2:

singularity run --cleanenv \
                -B ${BIDS_dir}:/rawdata \
                -B ${BIDS_dir}/derivatives:/derivatives \
                -B ${fmriprep_output_dir}:/fmriprep_output \
                $BMP_3RD_PATH/cvrmap-${cvrmap_version}.sif \
                /rawdata \
                /derivatives/cvrmap-${cvrmap_version} \
                --participant_label ${subject_ID} \
                --skip_bids_validator \
                --fmriprep_dir /fmriprep_output \
                --task co2 \
                --space MNI152NLin2009cAsym:res-2 \
                participant

INFO (2024-12-09-08-11-54) Version: 2.0.25
INFO (2024-12-09-08-11-54) Indexing BIDS dataset...
INFO (2024-12-09-08-11-56) Bids directory: /rawdata
INFO (2024-12-09-08-11-56) Fmriprep directory: /fmriprep_output
INFO (2024-12-09-08-11-56) Subject(s) to analyse: ['vci016']
INFO (2024-12-09-08-11-56) Task to analyse: co2
INFO (2024-12-09-08-11-56) Selected space: MNI152NLin2009cAsym
INFO (2024-12-09-08-11-56) Selected resolution: 2
INFO (2024-12-09-08-11-56) Running for participant vci016
Traceback (most recent call last):
  File "/usr/local/bin/cvrmap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/cvrmap.py", line 72, in main
    melodic_mixing_df, melodic_mixing_path = get_melodic_mixing(basic_filter, layout)
                                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/io_tools.py", line 467, in get_melodic_mixing
    melodic_mixing = layout.get(**_bids_filter)[0]
                     ~~~~~~~~~~~~~~~~~~~~~~~~~~^^^
IndexError: list index out of range

Hello,
this is a different problem. I'll open another issue (see #6 ) to keep things clean. But the original issue is solved. Feel free to reopen if necessary.

@arovai
Copy link
Contributor
arovai commented Dec 10, 2024

I reran FMRIPrep without specifying res2 for MNI152NLin2009cAsym. CVRmap gives a different error:

singularity run --cleanenv \
                -B ${BIDS_dir}:/rawdata \
                -B ${BIDS_dir}/derivatives:/derivatives \
                -B ${fmriprep_output_dir}:/fmriprep_output \
                $BMP_3RD_PATH/cvrmap-${cvrmap_version}.sif \
                /rawdata \
                /derivatives/cvrmap-${cvrmap_version} \
                --participant_label ${subject_ID} \
                --skip_bids_validator \
                --fmriprep_dir /fmriprep_output \
                --task co2 \
                --space MNI152NLin2009cAsym \
                participant

INFO (2024-12-09-10-05-22) Version: 2.0.25
INFO (2024-12-09-10-05-22) Indexing BIDS dataset...
INFO (2024-12-09-10-05-24) Bids directory: /rawdata
INFO (2024-12-09-10-05-24) Fmriprep directory: /fmriprep_output
INFO (2024-12-09-10-05-24) Subject(s) to analyse: ['vci016']
INFO (2024-12-09-10-05-24) Task to analyse: co2
INFO (2024-12-09-10-05-24) Selected space: MNI152NLin2009cAsym
INFO (2024-12-09-10-05-24) Running for participant vci016
Traceback (most recent call last):
  File "/usr/local/bin/cvrmap", line 8, in <module>
    sys.exit(main())
             ^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/cvrmap.py", line 90, in main
    physio = get_physio_data(basic_filter, layout)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/io_tools.py", line 427, in get_physio_data
    physio.bids_load(layout, physio_filter, 'timecourse', **{'col': 1})
  File "/usr/local/lib/python3.11/site-packages/cvrmap/utils/processing.py", line 64, in bids_load
    data = numpy.loadtxt(data_path, usecols=kwargs['col'])
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/numpy/lib/npyio.py", line 1356, in loadtxt
    arr = _read(fname, dtype=dtype, comment=comment, delimiter=delimiter,
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/numpy/lib/npyio.py", line 999, in _read
    arr = _load_from_filelike(
          ^^^^^^^^^^^^^^^^^^^^
ValueError: invalid column index 1 at row 1 with 1 columns

This is also another issue, I've open another one, see #7.

@arovai arovai closed this as completed Dec 10, 2024
@arovai arovai reopened this Dec 10, 2024
@arovai arovai closed this as completed Dec 10, 2024
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

2 participants
0