I've been trying to open compressed fMRI data (.nii.gz file) on MATLAB, using the load_nifti function.
EDIT-> I had initially tried to use the load_nii function, but MATLAB did not recognize this command and itself suggested using the load_nifti command instead. My version of MATLAB has not 3rd party toolboxes or apps installed - the load_nifti (formerly load_nii function) have been integrated within the image processing toolbox since R2017b.
I am using MATLAB on LINUX Ubuntu version 22
Since there are many subjects, I've made a root path function in order to access this data.
root_path = ['/media/megan2/VERBATIM HD/dHCP_data/sub-' subj '/' 'ses-' ses_id '/' task];
Where subj and ses_id are variables that change.
The workspace has the list of subj and ses_id in order to find the subject data.
The code I'm using to open the file:
phaseBP = load_nifti([root_path '/BP_demeaned_0.033-0.07Hz_sub-' subj '_' 'ses-' ses_id '_task-rest_desc-preproc_bold-cropped.nii.gz']);
Running the code gives me this:
cd /media/megan2/VERBATIM HD
zcat /media/megan2/VERBATIM HD/dHCP_data/sub-CC00852XX11/ses-28210/func/BP_demeaned_0.033-0.07Hz_sub-CC00852XX11_ses-28210_task-rest_desc-preproc_bold-cropped.nii.gz > /tmp/tpb5ca9cf4_93fd_45f1_abdf_a96530646c80.load_nifti.m.nii
ERROR: gzip: /media/megan2/VERBATIM.gz: No such file or directory
gzip: HD/dHCP_data/sub-CC00852XX11/ses-28210/func/BP_demeaned_0.033-0.07Hz_sub-CC00852XX11_ses-28210_task-rest_desc-preproc_bold-cropped.nii.gz: No such file or directory
This just displays an empty 0x0 matrix in the workspace.
Things I've already tried:
- I've double checked to ensure that the desired .nii.gz file is within the mentioned directory.
- I've tested using the readnifti function to ensure that the data can be accessed that way - it can so MATLAB can find the data, but gives me an error when I try to use the load_nifti function ( which I have to use in this case since I need the structure from the data and it's headers (not an array which readnifti gives. I've ensure that I have set my directory correctly
- I've used the load_nifti function by directly searching for the file name: /media/megan2/VERBATIM HD/dHCP_data/sub-CC00852XX11/ses-28210/func/BP_demeaned_0.033-0.07Hz_sub-CC00852XX11_ses-28210_task-rest_desc-preproc_bold-cropped.nii.gz - which has given me the same result.