help
help > RE: Extracting voxel-time-series for ROI-voxels
Nov 18, 2014 04:11 PM | Tobias Meindl - TU Munich
RE: Extracting voxel-time-series for ROI-voxels
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}
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
Title | Author | Date |
---|---|---|
Tobias Meindl | Oct 25, 2014 | |
Tobias Meindl | Nov 18, 2014 | |
Alfonso Nieto-Castanon | Nov 18, 2014 | |
Tobias Meindl | Nov 25, 2014 | |
Alfonso Nieto-Castanon | Nov 26, 2014 | |
Alfonso Nieto-Castanon | Nov 15, 2014 | |