help > RE: Extracting voxel-time-series for ROI-voxels
Nov 18, 2014  06:11 PM | Alfonso Nieto-Castanon - Boston University
RE: Extracting voxel-time-series for ROI-voxels
Dear Tobias,

The code looks perfectly correct. I also agree that the most likely reason for the observed discrepancy is that the ROI data is (typically) extracted from the unsmoothed volumes (look in Setup.Functionals the field "Extract ROI BOLD signals from"), while your code is extracting the ROI timeseries from the smoothed volumes (the ones specified in Setup.Functionals "Extract voxel BOLD signals from"). To double-check this explanation I would simply add a new ROI, uncheck for this ROI the "ROI BOLD sources" checkbox (so the ROI BOLD timeseries will be extracted from the same -smoothed- volumes as your voxel-level data), and rerun (without overwriting the already computed subjects/ROIs) the Setup and Denoising steps. For this new ROI you should observe exactly the same denoised timeseries from the CONN output (preprocessing/ROI_Subject*.mat file) as that obtained from your scripts. 

Hope this helps
Alfonso
Originally posted by Tobias Meindl:
Dear Alfonso,

thank you very much for your answer. I feel sorry I didn't have time to try your suggestions earlier.

I used the files you mentioned and there still is a discrepancy between the mean I calculated (see the code below) and the displayed time course in the data in the first level-Analysis window in the figure beneath the "frequency bands input option".
As before I extracted this displayed data by introducing a breakpoint at line 1989 in the conn.m file from the variable CONN_h.menus.m_analyses.X the same data (for the aal Precentral Left-ROI) in my case is contained in data{1,4} in the ROI_Subject001_Condition001.mat file

The observed discrepancy as before is bigger for smaller ROIs. Spatial smoothing should affect the mean of a smaller ROI to a bigger extent, as a larger percentage of the ROI's voxels is influenced by nearby voxels not contained in the ROI. Am I correct that the discrepancy between the mean I computed myself and the one displayed by conn is for the same reason as you explained in an earlier post in the forum in July to Daniele Mascali, i.e. that the ROI-time course in data{1,4} is computed from unsmoothed volumes whereas the niftiDATA_Subject001_Condition001.nii contains spatially smoothed data?

As I am not entirely sure whether this explanation is correct I would be very grateful if you could have a (very quick) look on the code below whether this looks alright for you to extract ROI-voxels.

And furthermore do you think that the data in niftiDATA_Subject001_Condition001.nii beeing confound corrected and scaled to whole-brain-psc is a good starting point for further exploratory tests for example looking at differences in voxel'wise variance between groups or fitting svar models?

Thank you very much for the effort you put in your last answer already!
Kind regards
Tobias

% Get mean shown by conn:
load('/XXXXXXX/conn_data/results/preprocessing/ROI_Subject001_Condition001.mat');
Precentral_L = data{1,4};


% Read preprocessed Data
datadir = '/XXXXXXXX/conn_data/results/preprocessing';
fname = 'niftiDATA_Subject001_Condition001.nii';
Data2Read = fullfile(datadir, fname);
HeaderInfo = spm_vol(Data2Read);
Data = spm_read_vols(HeaderInfo);

% Get coordinates of ROI-voxels
load('/XXXXXXX/conn_data/data/REX_Subject001_Session001_ROI4.mat');
coordinates = params.ROIinfo.voxels{1,1}{1,1}; % Precentral Left; coordinates in mm

% Purpose: convert mm to voxel-indices.
% the following is taken from conn_convertcoordinates:

xyz1 = coordinates;
dim2 = HeaderInfo(1).dim;
M2 = HeaderInfo(1).mat;

dim2=dim2(1:3);
xyz2=[xyz1(:,1:3),ones(size(xyz1,1),1)]*pinv(M2)';
xyz2=xyz2(:,1:3);
xyz2=max(1,min(repmat(dim2,[size(xyz2,1),1]),round(xyz2)));
xyz2=mat2cell(xyz2,size(xyz2,1),ones(1,size(xyz2,2)));


% Extract ROI-voxels:

nvoxels = size(coordinates,1);
nobservations = size(Data,4);
tmp = zeros(nobservations, nvoxels);
for i = 1:nvoxels
tmp(:,i) = Data(xyz2{1,1}(i), xyz2{1,2}(i), xyz2{1,3}(i),:); % tmp: matrix with columns containing all observations of one of the rois voxels (voxel-timecourse)
end

ExtractedMean = mean(tmp,2); % not identical to values from displayed in conn i.e. contained in data{1,4}

Threaded View

TitleAuthorDate
Tobias Meindl Oct 25, 2014
Tobias Meindl Nov 18, 2014
RE: Extracting voxel-time-series for ROI-voxels
Alfonso Nieto-Castanon Nov 18, 2014
Tobias Meindl Nov 25, 2014
Alfonso Nieto-Castanon Nov 26, 2014
Alfonso Nieto-Castanon Nov 15, 2014