- MATLAB
- SPM12 (added to MATLAB path)
- DPABI (added to MATLAB path; start with
dpabi) - (Optional) dcm2niix for DICOM→NIfTI
data/
sub-001/
anat/ sub-001_T1.nii(.gz)
func/ sub-001_rest.nii(.gz)
sub-002/
anat/ sub-002_T1.nii(.gz)
func/ sub-002_rest.nii(.gz)
dcm2niix -z y -f sub-001_rest -o data/sub-001/func DICOM_FUNC_DIR/
dcm2niix -z y -f sub-001_T1 -o data/sub-001/anat DICOM_T1_DIR/In MATLAB:
dpabiIn DPARSFA preprocessing GUI:
- Set Working Directory
- Run preprocessing (typical steps):
- Remove first N volumes
- Slice timing (optional, depends on acquisition)
- Realign (motion correction) + motion metrics (e.g., FD)
- T1 segmentation / coregistration
- Normalize to MNI
- Smoothing (optional; depends on your ROI strategy)
- Detrend
- Nuisance regression (motion/WM/CSF; optional GSR)
- Band-pass filtering (commonly 0.01–0.08 Hz)
Output directories usually look like FunImg* under the working directory (exact naming depends on your settings).
- Use either:
- Single multi-label atlas (integer labels 1..N), or
- Multiple binary ROI masks
- Ensure the ROI atlas/masks are in the same space/resolution as the preprocessed fMRI you will use (reslice if needed).
In DPABI:
- Open Extract ROI Time Courses
- Input fMRI: select the final preprocessed 4D fMRI directory you want (e.g.,
FunImgARCWF-like) - ROI definition: select atlas or ROI masks
- Run extraction
Typical outputs:
WorkingDir/Results/ROISignals_*/
ROISignals_SubXXX.mat
ROISignals_SubXXX.txt
ROI_OrderKey_SubXXX.tsv
% === Config ===
workDir = '/path/to/WorkingDir';
roiResDir = fullfile(workDir, 'Results', 'ROISignals_FunImgARCWF'); % adjust to your folder name
outDir = fullfile(workDir, 'Export_ROISignals_CSV');
if ~exist(outDir, 'dir'); mkdir(outDir); end
files = dir(fullfile(roiResDir, 'ROISignals_Sub*.mat'));
for k = 1:numel(files)
inMat = fullfile(roiResDir, files(k).name);
S = load(inMat); % typically contains variable "ROISignals"
X = S.ROISignals; % [T x N]
[~, base, ~] = fileparts(files(k).name);
outCsv = fullfile(outDir, [base '.csv']);
writematrix(X, outCsv);
end
disp('Done.');import scipy.io as sio
import pandas as pd
mat = sio.loadmat("ROISignals_Sub001.mat")
X = mat["ROISignals"] # shape: (T, N)
pd.DataFrame(X).to_csv("ROISignals_Sub001.csv", index=False)We gratefully acknowledge DPABI and its documentation provided by R-fMRI Network (http://rfmri.net/dpabi), which enabled the preprocessing and ROI time-series extraction workflow used in this project.
- Raw 3D T1w sMRI (NIfTI)
- MNI152 T1 template (NIfTI)
- (Optional) MNI-space brain mask (NIfTI) for skull stripping
- Load T1w sMRI
- N4 Bias Field Correction
- Correct intensity inhomogeneity across the image.
- Resampling (optional but recommended)
- Resample to a consistent isotropic voxel spacing (e.g., 1 mm) to standardize geometry.
- Skull Stripping
- Remove non-brain tissues (using a subject-space method or an MNI-space mask after normalization).
- Linear Registration & Spatial Normalization to MNI152
- Perform rigid/affine registration to align the subject T1w to the MNI152 template.
- Resample the image into MNI space.
- Intensity Normalization (recommended)
- Apply z-score normalization or other robust intensity scaling within the brain mask.
- Downsample / Reshape to 96×96×96
- Resample the MNI-aligned brain volume to a fixed grid size 96×96×96.
- Use linear interpolation for intensity images.
- Preprocessed 3D volume in MNI space with fixed size: 96×96×96 (NIfTI)