How to display 3D image from nii file (openfMRI data) and transfer it to DICOM file?

20 次查看(过去 30 天)
Hi,
I want to know how to display 3D image from open fMRI data in online Matlab.
The data can be downloaded from the below link.
I only operated niftiread function and the acquisited volume data seems 64x64x30x76 int16.
V = niftiread("4_overt_word_repetition.nii")
I would like to ask you to write the codes line by line.
In addition, If you know how to transfer the fMRI data to DICOM file, please let me know.
Thanks.

回答(1 个)

Meet
Meet 2023-3-8
Hi,
To display a 3D image from open fMRI data in online Matlab, you can follow these general steps:
  1. Download the fMRI data from an open data repository such as the OpenfMRI database.
  2. Load the fMRI data into Matlab using the appropriate toolbox or code. There are several toolboxes available for analyzing and processing fMRI data in Matlab, such as SPM (Statistical Parametric Mapping), FSL (FMRIB Software Library), and AFNI (Analysis of Functional NeuroImages).
  3. Preprocess the fMRI data by correcting for motion artifacts, spatially normalizing the data to a standard template, and applying spatial smoothing to reduce noise.
  4. Extract the brain activation patterns from the preprocessed fMRI data using a suitable statistical method such as general linear modeling or independent component analysis.
  5. Visualize the brain activation patterns in a 3D image using the Matlab graphics functions such as the "surf" or "isosurface" commands. You can also use third-party toolboxes such as BrainNet Viewer to generate 3D brain networks and connectomes.
Here is an example code snippet that demonstrates how to display a 3D image of brain activation using the SPM toolbox in Matlab:
% Load the fMRI data using SPM
addpath('path/to/SPM');
spm('defaults','fmri');
spm_jobman('initcfg');
matlabbatch{1}.spm.stats.fmri_spec.dir = {'path/to/output/directory'};
matlabbatch{1}.spm.stats.fmri_spec.sess.scans = {'path/to/fMRI/data.nii'};
spm_jobman('run', matlabbatch);
% Preprocess the fMRI data using SPM
spm_jobman('initcfg');
matlabbatch{1}.spm.spatial.realign.estwrite.data = {'path/to/fMRI/data.nii'};
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.quality = 0.9;
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.sep = 4;
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.fwhm = 5;
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.rtm = 0;
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.interp = 2;
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.wrap = [0 0 0];
matlabbatch{1}.spm.spatial.realign.estwrite.eoptions.weight = '';
spm_jobman('run', matlabbatch);
% Extract brain activation patterns using SPM
spm_jobman('initcfg');
matlabbatch{1}.spm.stats.fmri_est.spmmat = {'path/to/output/directory/SPM.mat'};
spm_jobman('run', matlabbatch)
% Display 3D image of brain activation using SPM
spm_jobman('initcfg');
matlabbatch{1}.spm.stats.results.spmmat = {'path/to/output/directory/SPM.mat'};
matlabbatch{1}.spm.stats.results.conspec.contrasts = 1;
matlabbatch{1}.spm.stats.results.conspec.threshdesc = 'FWE';
matlabbatch{1}.spm.stats.results.conspec.thresh = 0.05;
matlabbatch{1}.spm.stats.results.conspec.extent = 10;
matlabbatch{1}.spm.stats.results.print = false;
spm_jobman('run', matlabbatch);
Note that this code is just an example, and you may need to modify it depending on your specific data and requirement.

类别

Help CenterFile Exchange 中查找有关 MRI 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by