MLDataAnalytics / pNet

pNet is a Python package for computing personalized, sparse, non-negative large-scale functional networks from functional magnetic resonance imaging (fMRI) data, particularly resting state fMRI data.
5 stars 1 forks source link

The shapes of Brain_Mask and scan_data are not the same when scan_data is a 4D matrix #1

Closed RyannChaw closed 2 months ago

RyannChaw commented 2 months ago

Hi expert, I tried pNet by using fmriprep preprocessed data, with sub-001_task-rest_space-MNI152NLin2009cAsym_desc-preproc_bold.nii as input data, and set the config file with the following code:

file_Brain_Template = "/media/gerd/WI/Yuan/pNet/src/pnet/Brain_Template/MNI_Volume/Brain_Template.json.zip"
## date type and format information
# data type is volume
dataType = "Volume"
# data format is Volume data with 91x109X91 voxles in MNI space
dataFormat = "Volume (*.nii, *.nii.gz, *.mat)"

But the following error occurs: docker run -v /media/gerd/pnet:/media/gerd/pnet -v /media/gerd/pNet:/media/gerd/pNet -v /media/gerd/BIDS/derivatives/out:/media/gerd/BIDS/derivatives/out mldataanalytics/fmripnet -c /media/gerd/pnet/config.toml Traceback (most recent call last): File "/opt/conda/envs/fmripnet/lib/python3.8/site-packages/pnet/cli/fmripnet.py", line 120, in main(config_file, hpc) File "/opt/conda/envs/fmripnet/lib/python3.8/site-packages/pnet/cli/fmripnet.py", line 56, in main pnet.workflow( File "/opt/conda/envs/fmripnet/lib/python3.8/site-packages/pnet/Workflow/Workflow_Func.py", line 186, in workflow run_FN_Computation_torch(dir_pnet_result) File "/opt/conda/envs/fmripnet/lib/python3.8/site-packages/pnet/Module/FN_Computation_torch.py", line 146, in run_FN_Computation_torch Data, CHeader, NHeader = load_fmri_scan(file_scan_list, dataType=dataType, dataFormat=dataFormat, nTPoints=nTPoints, Reshape=True, Brain_Mask=Brain_Mask, File "/opt/conda/envs/fmripnet/lib/python3.8/site-packages/pnet/Module/Data_Input.py", line 461, in load_fmri_scan scan_data = reshape_fmri_data(scan_data, dataType, Brain_Mask) File "/opt/conda/envs/fmripnet/lib/python3.8/site-packages/pnet/Module/Data_Input.py", line 1148, in reshape_fmri_data raise ValueError('The shapes of Brain_Mask and scan_data are not the same when scan_data is a 4D matrix') ValueError: The shapes of Brain_Mask and scan_data are not the same when scan_data is a 4D matrix

BTW I also tried hcp-pipeline preprocessed data with task-rest_dir-RL_LR_Atlas_MSMAll_InitalReg_2_d40_WRN_hp0_clean.dtseries.nii as input and the config file with the following info, it worked well.

file_Brain_Template = "/media/ubuntu/chaw2/pNet/src/pnet/Brain_Template/HCP_Surface/Brain_Template.json.zip"
## date type and format information
# data type is surface
dataType = "Surface"
# data format is HCP surface
dataFormat = "HCP Surface (*.cifti, *.mat)"

I'm wondering if I'm not setting it up correctly somewhere when processing volume data as input? Thank you so much. Yuan

MLDataAnalytics commented 2 months ago

Could you check your data header information?

It works with a preprocess data with header information, like

sizeof_hdr 348 data_type FLOAT32 dim0 4 dim1 91 dim2 109 dim3 91 dim4 1200 dim5 1 dim6 1 dim7 1 vox_units mm time_units s datatype 16 nbyper 4 bitpix 32 pixdim0 -1.000000 pixdim1 2.000000 pixdim2 2.000000 pixdim3 2.000000 pixdim4 0.720000 pixdim5 0.000000 pixdim6 0.000000 pixdim7 0.000000 vox_offset 352 cal_max 0.000000 cal_min 0.000000 scl_slope 1.000000 scl_inter 0.000000 phase_dim 0 freq_dim 0 slice_dim 0 slice_name Unknown slice_code 0 slice_start 0 slice_end 0 slice_duration 0.000000 toffset 0.000000 intent Unknown intent_code 0 intent_name intent_p1 0.000000 intent_p2 0.000000 intent_p3 0.000000 qform_name MNI_152 qform_code 4 qto_xyz:1 -2.000000 0.000000 -0.000000 90.000000 qto_xyz:2 0.000000 2.000000 -0.000000 -126.000000 qto_xyz:3 0.000000 0.000000 2.000000 -72.000000 qto_xyz:4 0.000000 0.000000 0.000000 1.000000 qform_xorient Right-to-Left qform_yorient Posterior-to-Anterior qform_zorient Inferior-to-Superior sform_name MNI_152 sform_code 4 sto_xyz:1 -2.000000 0.000000 0.000000 90.000000 sto_xyz:2 0.000000 2.000000 0.000000 -126.000000 sto_xyz:3 0.000000 0.000000 2.000000 -72.000000 sto_xyz:4 0.000000 0.000000 0.000000 1.000000 sform_xorient Right-to-Left sform_yorient Posterior-to-Anterior sform_zorient Inferior-to-Superior file_type NIFTI-1+ file_code 1 descrip FSL5.0 aux_file

RyannChaw commented 2 months ago

Thanks for your reply.It looks like that I need to resample the data after fmriprep preprocessing. I finally chose to use Xcpd to do the post-processing and get the cifti data, then ran pNet on the surface level. It works well.

MLDataAnalytics commented 2 months ago

Thanks for the update.