MICA-MNI / BrainSpace

BrainSpace is an open-access toolbox that allows for the identification and analysis of gradients from neuroimaging and connectomics datasets | available in both Python and Matlab |
http://brainspace.readthedocs.io
BSD 3-Clause "New" or "Revised" License
180 stars 72 forks source link

Errors in Tutorial 0 #117

Open ozgum opened 4 months ago

ozgum commented 4 months ago

Hello,

We are learning to use BrainSpace toolbox for gradient analysis on 1 subject. We did the minimal preprocessing (no smoothing, no temporal filtering, no confound regression) in fmriprep (with FreeSurfer’s recon-all) as suggested. We tried to run the Tutorial 0’s code, we are getting errors in “import the dataset as timeseries”, “confound regression” steps.

Our computing environment is Ubuntu 22.04.4 LTS, Python 3.12.2.

We tried the following code:

import nibabel as nib
import numpy as np

filename = 'filename.{}.mgz' # where {} will be replaced with 'lh' and 'rh'
timeseries = [None] * 2
for i, h in enumerate(['lh', 'rh']):
    timeseries[i] = nib.load(filename.format(h)).get_fdata().squeeze()
timeseries = np.vstack(timeseries)

We do not have an functional fmriprep output with .mgz extension, and any lh.mgz rh.mgz files. So, since our file is here:

~/Desktop/deneme/mdd/bids/derivatives/sub-02/func/sub-02_task-rest_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz

We ran the code by writing our output path:

import nibabel as nib
import numpy as np

filename = '~/Desktop/deneme/mdd/bids/derivatives/sub-02/func/sub-02_task-rest_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz' # where {} will be replaced with 'lh' and 'rh'
timeseries = [None] * 2
for i, h in enumerate(['lh', 'rh']):
    timeseries[i] = nib.load(filename.format(h)).get_fdata().squeeze()
timeseries = np.vstack(timeseries)

Then we ran:

from brainspace.datasets import fetch_timeseries_preprocessing
timeseries = fetch_timeseries_preprocessing()
from nilearn.interfaces.fmriprep import load_confounds_strategy
confounds_out = load_confounds_strategy("~/Desktop/deneme/mdd/bids/derivatives/sub-02/func/sub-02_task-rest_space-MNI152NLin2009cAsym_res-2_desc-preproc_bold.nii.gz", denoise_strategy='simple')

We got this error:

ValueError: Could not find associated confound file. The functional derivatives should exist under the same parent directory.

We did not understand this error because our confounds file (sub-02_task-rest_desc-confounds_timeseries.tsv) is in the same directory: “~/Desktop/deneme/mdd/bids/derivatives/sub-02/func”.

Then we saw a different code in your plot_tutorial0.py file to extract the confound columns, so we ran:

import load_confounds
confounds_out=load_confounds("~/Desktop/deneme/mdd/bids/derivatives/sub-02/func/sub-02_task-rest_desc-confounds_timeseries.tsv",
                           strategy='minimal',
                           n_components=0.95,
                           motion_model='6params')

We got this error:

TypeError: 'module' object is not callable.

We are not able to move forward to other tutorials due to these errors, can you please help us figure out these issues?

Thanks in advance, any help is appreciated.

Best, Ozgum