|
@@ -0,0 +1,19 @@
|
|
|
+function [dvars_per_vol, mean_dvars]=calculate_dvars(data_matrix,censored_vols)
|
|
|
+% routine for calculation of dvars for QC'ing dHCP denoised fMRI data
|
|
|
+%
|
|
|
+% data_matrix - Ntimepoints by Nvoxels
|
|
|
+% censored_vols - as per file: sub-{sub}_ses-{ses}_task-rest_desc-censored_vols.txt
|
|
|
+
|
|
|
+% dvars_per_vol - Ntimepoints by 1; will be zero-valued if differential
|
|
|
+% involves a censored volume; the first element is always zero-valued
|
|
|
+% mean_dvars - mean over non-zeroed dvars_per_vol
|
|
|
+
|
|
|
+
|
|
|
+censored_vols=censored_vols+1; % as they are counted from 0
|
|
|
+
|
|
|
+ind_not_to_include=unique([1 censored_vols censored_vols+1]);
|
|
|
+ind_not_to_include(ind_not_to_include>size(data_matrix,1))=[];
|
|
|
+dY=diff(data_matrix).^2;
|
|
|
+dvars_per_vol=[0;mean(dY,2)];
|
|
|
+dvars_per_vol(ind_not_to_include)=0;
|
|
|
+mean_dvars=mean(dvars_per_vol(dvars_per_vol>0));
|