<div dir="ltr">Dear Mohammed,<div><br></div><div><p class="MsoNormal">> Is there any alternative method to extract the ERP values after MPT clustering or to extract the P values after run statistics by MPT GUI?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">I have a utility tool for that. I gave it to Ozgur Balkan for which he added me to his latest IEEE conf proc paper. If you are interested in please let me know. I can send it to you privately. However, you MUST edit it to adjust to your data (hopefully that is straightforward, but you have to understand the data structure of MPT.)</p><p class="MsoNormal"><br></p><p class="MsoNormal">> About the anatomical regions, do you know how can I do that?</p><p class="MsoNormal"><br></p><p class="MsoNormal">I pasted below a part of code from my alpha version of groupSIFT (this name is only tentative) plugin. Beware that there are more than 300 lines. No claim no return, use it at your own risk-kind of thing.</p><p class="MsoNormal"><br></p><p class="MsoNormal">Makoto</p><p class="MsoNormal"><br></p><p class="MsoNormal"><br></p></div><div class="gmail_extra"><br></div><div class="gmail_extra"><div class="gmail_extra">% --- Executes on button press in selectFilesButton.</div><div class="gmail_extra">function selectFilesButton_Callback(hObject, eventdata, handles)</div><div class="gmail_extra">% hObject    handle to selectFilesButton (see GCBO)</div><div class="gmail_extra">% eventdata  reserved - to be defined in a future version of MATLAB</div><div class="gmail_extra">% handles    structure with handles and user data (see GUIDATA)</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Obtain multiple .set files</div><div class="gmail_extra">[allFiles, workingFolder] = uigetfile('*.set', 'MultiSelect', 'on');</div><div class="gmail_extra">if ~any(workingFolder)</div><div class="gmail_extra">    disp('Cancelled.')</div><div class="gmail_extra">    return</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Obtain user input file name</div><div class="gmail_extra">userInputFilename = get(handles.fileNameEdit, 'String');</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Move to the working folder</div><div class="gmail_extra">cd(workingFolder)</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Load empty dipolePairAndMeasure from eeglabroot/plugins/groupSIFT/+pr: Thanks Clement!</div><div class="gmail_extra">dipolePairAndMeasureObj = pr.dipolePairAndMeasure;</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Load all .set data located under the working folder</div><div class="gmail_extra">ALLEEG = [];</div><div class="gmail_extra">for n = 1:length(allFiles)</div><div class="gmail_extra">    loadName = allFiles{n};</div><div class="gmail_extra">    EEG = pop_loadset('filename', loadName,'filepath',workingFolder, 'loadmode', 'info');</div><div class="gmail_extra">    [ALLEEG, EEG, CURRENTSET] = eeg_store( ALLEEG, EEG, 0 );</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Compute how many IC combinations in all subjects</div><div class="gmail_extra">numICs = zeros(length(ALLEEG),1);</div><div class="gmail_extra">for n = 1:length(ALLEEG)</div><div class="gmail_extra">    numICs(n) = size(ALLEEG(1,n).icaweights,1);</div><div class="gmail_extra">end</div><div class="gmail_extra">numIcCombination = sum(numICs.^2);</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Assign unique IDs to dipoles</div><div class="gmail_extra">if get(handles.rpdcButton,'value')==1</div><div class="gmail_extra">    timeFreqSize = size(squeeze(ALLEEG(1).CAT.Conn.RPDC(  1,1,:,:)));</div><div class="gmail_extra">else</div><div class="gmail_extra">    timeFreqSize = size(squeeze(ALLEEG(1).CAT.Conn.dDTF08(1,1,:,:)));</div><div class="gmail_extra">end</div><div class="gmail_extra">latencies = ALLEEG(1).CAT.Conn.erWinCenterTimes;</div><div class="gmail_extra">frequencies = ALLEEG(1).CAT.Conn.freqs;</div><div class="gmail_extra">dimensionLabels= ALLEEG(1).CAT.Conn.dims;</div><div class="gmail_extra">dipolePairAndMeasureObj.linearizedMeasure = zeros([numIcCombination timeFreqSize(1)*timeFreqSize(2)]);</div><div class="gmail_extra">dipoleCounter = 0;</div><div class="gmail_extra">counter = 1;</div><div class="gmail_extra">for n = 1:length(ALLEEG)</div><div class="gmail_extra">    numberOfSessiondipoles = length(ALLEEG(n).dipfit.model);</div><div class="gmail_extra">    dipoleLocation = [];</div><div class="gmail_extra">    dipoleResidualVariance = [];</div><div class="gmail_extra">    for m = 1:numberOfSessiondipoles</div><div class="gmail_extra">        dipoleLocation(m,:)       = ALLEEG(n).dipfit.model(m).posxyz(1,:);</div><div class="gmail_extra">        dipoleResidualVariance(m) = ALLEEG(n).dipfit.model(m).rv;</div><div class="gmail_extra">    end;</div><div class="gmail_extra">    dipoleId = (dipoleCounter+1):(dipoleCounter+length(dipoleLocation));</div><div class="gmail_extra">    dipoleCounter = dipoleCounter + length(dipoleLocation);</div><div class="gmail_extra">    </div><div class="gmail_extra">    for m = 1:length(dipoleLocation) % from location: confirm it with ALLEEG(1,1).CAT.Conn: dims: {'var_to'  'var_from'  'freq'  'time'}</div><div class="gmail_extra">        for k = 1:length(dipoleLocation) % to location</div><div class="gmail_extra">            dipolePairAndMeasureObj.from.location = cat(1, dipolePairAndMeasureObj.from.location, ALLEEG(n).dipfit.model(m).posxyz(1,:));</div><div class="gmail_extra">            dipolePairAndMeasureObj.from.residualVariance(end+1,1) = ALLEEG(n).dipfit.model(m).rv;</div><div class="gmail_extra">            dipolePairAndMeasureObj.to.location = cat(1, dipolePairAndMeasureObj.to.location, ALLEEG(n).dipfit.model(k).posxyz(1,:));</div><div class="gmail_extra">            if m == k</div><div class="gmail_extra">                dipolePairAndMeasureObj.linearizedMeasure(counter,:) = zeros(timeFreqSize(1)*timeFreqSize(2),1);</div><div class="gmail_extra">            else</div><div class="gmail_extra">                if get(handles.rpdcButton,'value')==1 % Again, ALLEEG(1,1).CAT.Conn: dims: {'var_to'  'var_from'  'freq'  'time'}</div><div class="gmail_extra">                    tmpTimeFreqMatrix = squeeze(ALLEEG(n).CAT.Conn.RPDC(  k,m,:,:));</div><div class="gmail_extra">                else</div><div class="gmail_extra">                    tmpTimeFreqMatrix = squeeze(ALLEEG(n).CAT.Conn.dDTF08(k,m,:,:));</div><div class="gmail_extra">                end</div><div class="gmail_extra">                dipolePairAndMeasureObj.linearizedMeasure(counter,:) = tmpTimeFreqMatrix(:);</div><div class="gmail_extra">            end</div><div class="gmail_extra">            dipolePairAndMeasureObj.sessionId(counter,1) = n;</div><div class="gmail_extra">            dipolePairAndMeasureObj.fromDipoleId(counter,1) = dipoleId(m);</div><div class="gmail_extra">            dipolePairAndMeasureObj.toDipoleId(counter,1)   = dipoleId(k);</div><div class="gmail_extra">            counter = counter + 1;</div><div class="gmail_extra">        end</div><div class="gmail_extra">    end</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Find unique dipoles</div><div class="gmail_extra">uniqueDipole = pr.dipole;</div><div class="gmail_extra">[~,fromId,fromIdReverse] = unique(dipolePairAndMeasureObj.fromDipoleId, 'stable');</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Extract coordinates + residual variance of the unique dipoles</div><div class="gmail_extra">uniqueDipole.location = dipolePairAndMeasureObj.from.location(fromId,:);</div><div class="gmail_extra">uniqueDipole.residualVariance = dipolePairAndMeasureObj.from.residualVariance(fromId);</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Load headGrid cubes</div><div class="gmail_extra">headGrid = pr.headGrid;</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Set Gaussian smoothing kernel</div><div class="gmail_extra">    % FWHM = 2.355*sigma See <a href="https://en.wikipedia.org/wiki/Full_width_at_half_maximum">https://en.wikipedia.org/wiki/Full_width_at_half_maximum</a></div><div class="gmail_extra">    % 4.2  (FWHM==10mm, 12/23/2015)</div><div class="gmail_extra">    % 8.5  (FWHM==20mm, 06/24/2015)</div><div class="gmail_extra">    % 12.8 (FWHM==30mm, 09/05/2014)</div><div class="gmail_extra">    % 17.1 (FWHM==40mm, 01/06/2015)</div><div class="gmail_extra">    % Note that Gaussian is NOT truncated until reaching 150mm apart from the center</div><div class="gmail_extra">userInputKernelSize = str2num(get(handles.gaussianSizeEdit, 'String'));</div><div class="gmail_extra">standardDeviationOfEstimatedDipoleLocation = userInputKernelSize/2.355; % this calculates sigma in Gaussian equation</div><div class="gmail_extra">projectionParameter = pr.projectionParameter(standardDeviationOfEstimatedDipoleLocation);</div><div class="gmail_extra">projectionParameter.numberOfStandardDeviationsToTruncatedGaussaian = 150/standardDeviationOfEstimatedDipoleLocation;</div><div class="gmail_extra">[~,~,gaussianWeightMatrix]= pr.meanProjection.getProjectionMatrix(uniqueDipole, headGrid, projectionParameter);</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Define valid anatomical ROIs as EEG sources agreed by Scott and Makoto in Dec 2015; See below for the list</div><div class="gmail_extra">excludeRoiIdx = [21 22 37:42 71:78]; % 29 30 are insula... better to include?</div><div class="gmail_extra">includeRoiIdx = setdiff(1:88, excludeRoiIdx);</div><div class="gmail_extra">roiLabels = pr.regionOfInterestFromAnatomy.getAllAnatomicalLabels;</div><div class="gmail_extra">includeRoiLabels = roiLabels(includeRoiIdx);</div><div class="gmail_extra">excludeRoiLabels = roiLabels(excludeRoiIdx);</div><div class="gmail_extra">roiLabels = includeRoiLabels;</div><div class="gmail_extra"><br></div><div class="gmail_extra">% These regions are to be included</div><div class="gmail_extra">%     'Precentral_L'</div><div class="gmail_extra">%     'Precentral_R'</div><div class="gmail_extra">%     'Frontal_Sup_L'</div><div class="gmail_extra">%     'Frontal_Sup_R'</div><div class="gmail_extra">%     'Frontal_Sup_Orb_L'</div><div class="gmail_extra">%     'Frontal_Sup_Orb_R'</div><div class="gmail_extra">%     'Frontal_Mid_L'</div><div class="gmail_extra">%     'Frontal_Mid_R'</div><div class="gmail_extra">%     'Frontal_Mid_Orb_L'</div><div class="gmail_extra">%     'Frontal_Mid_Orb_R'</div><div class="gmail_extra">%     'Frontal_Inf_Oper_L'</div><div class="gmail_extra">%     'Frontal_Inf_Oper_R'</div><div class="gmail_extra">%     'Frontal_Inf_Tri_L'</div><div class="gmail_extra">%     'Frontal_Inf_Tri_R'</div><div class="gmail_extra">%     'Frontal_Inf_Orb_L'</div><div class="gmail_extra">%     'Frontal_Inf_Orb_R'</div><div class="gmail_extra">%     'Rolandic_Oper_L'</div><div class="gmail_extra">%     'Rolandic_Oper_R'</div><div class="gmail_extra">%     'Supp_Motor_Area_L'</div><div class="gmail_extra">%     'Supp_Motor_Area_R'</div><div class="gmail_extra">%     'Frontal_Sup_Medial_L'</div><div class="gmail_extra">%     'Frontal_Sup_Medial_R'</div><div class="gmail_extra">%     'Frontal_Med_Orb_L'</div><div class="gmail_extra">%     'Frontal_Med_Orb_R'</div><div class="gmail_extra">%     'Rectus_L'</div><div class="gmail_extra">%     'Rectus_R'</div><div class="gmail_extra">%     'Insula_L'</div><div class="gmail_extra">%     'Insula_R'</div><div class="gmail_extra">%     'Cingulum_Ant_L'</div><div class="gmail_extra">%     'Cingulum_Ant_R'</div><div class="gmail_extra">%     'Cingulum_Mid_L'</div><div class="gmail_extra">%     'Cingulum_Mid_R'</div><div class="gmail_extra">%     'Cingulum_Post_L'</div><div class="gmail_extra">%     'Cingulum_Post_R'</div><div class="gmail_extra">%     'Calcarine_L'</div><div class="gmail_extra">%     'Calcarine_R'</div><div class="gmail_extra">%     'Cuneus_L'</div><div class="gmail_extra">%     'Cuneus_R'</div><div class="gmail_extra">%     'Lingual_L'</div><div class="gmail_extra">%     'Lingual_R'</div><div class="gmail_extra">%     'Occipital_Sup_L'</div><div class="gmail_extra">%     'Occipital_Sup_R'</div><div class="gmail_extra">%     'Occipital_Mid_L'</div><div class="gmail_extra">%     'Occipital_Mid_R'</div><div class="gmail_extra">%     'Occipital_Inf_L'</div><div class="gmail_extra">%     'Occipital_Inf_R'</div><div class="gmail_extra">%     'Fusiform_L'</div><div class="gmail_extra">%     'Fusiform_R'</div><div class="gmail_extra">%     'Postcentral_L'</div><div class="gmail_extra">%     'Postcentral_R'</div><div class="gmail_extra">%     'Parietal_Sup_L'</div><div class="gmail_extra">%     'Parietal_Sup_R'</div><div class="gmail_extra">%     'Parietal_Inf_L'</div><div class="gmail_extra">%     'Parietal_Inf_R'</div><div class="gmail_extra">%     'SupraMarginal_L'</div><div class="gmail_extra">%     'SupraMarginal_R'</div><div class="gmail_extra">%     'Angular_L'</div><div class="gmail_extra">%     'Angular_R'</div><div class="gmail_extra">%     'Precuneus_L'</div><div class="gmail_extra">%     'Precuneus_R'</div><div class="gmail_extra">%     'Paracentral_Lobule_L'</div><div class="gmail_extra">%     'Paracentral_Lobule_R'</div><div class="gmail_extra">%     'Temporal_Sup_L'</div><div class="gmail_extra">%     'Temporal_Sup_R'</div><div class="gmail_extra">%     'Temporal_Pole_Sup_L'</div><div class="gmail_extra">%     'Temporal_Pole_Sup_R'</div><div class="gmail_extra">%     'Temporal_Mid_L'</div><div class="gmail_extra">%     'Temporal_Mid_R'</div><div class="gmail_extra">%     'Temporal_Pole_Mid_L'</div><div class="gmail_extra">%     'Temporal_Pole_Mid_R'</div><div class="gmail_extra">%     'Temporal_Inf_L'</div><div class="gmail_extra">%     'Temporal_Inf_R'</div><div class="gmail_extra">%</div><div class="gmail_extra">% These regions are to be excluded</div><div class="gmail_extra">%     'Olfactory_L'</div><div class="gmail_extra">%     'Olfactory_R'</div><div class="gmail_extra">%     'Hippocampus_L'</div><div class="gmail_extra">%     'Hippocampus_R'</div><div class="gmail_extra">%     'ParaHippocampal_L'</div><div class="gmail_extra">%     'ParaHippocampal_R'</div><div class="gmail_extra">%     'Amygdala_L'</div><div class="gmail_extra">%     'Amygdala_R'</div><div class="gmail_extra">%     'Caudate_L'</div><div class="gmail_extra">%     'Caudate_R'</div><div class="gmail_extra">%     'Putamen_L'</div><div class="gmail_extra">%     'Putamen_R'</div><div class="gmail_extra">%     'Pallidum_L'</div><div class="gmail_extra">%     'Pallidum_R'</div><div class="gmail_extra">%     'Thalamus_L'</div><div class="gmail_extra">%     'Thalamus_R'</div><div class="gmail_extra">%</div><div class="gmail_extra">% One can visualize these regions by running visualizeAnatomicalRoiWithNHimasBlobs.m contained by the groupSIFT folder.</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Obtain dipole density and centroids in each ROI</div><div class="gmail_extra">numberOfRegionsOfInterest = length(roiLabels);</div><div class="gmail_extra">dipoleProbabilityInRegion = zeros(uniqueDipole.numberOfDipoles, numberOfRegionsOfInterest);</div><div class="gmail_extra">roiCentroids = zeros(length(includeRoiLabels),3);</div><div class="gmail_extra">for i=1:numberOfRegionsOfInterest</div><div class="gmail_extra">    regionOfInterest(i) = pr.regionOfInterestFromAnatomy(pr.headGrid, roiLabels{i});</div><div class="gmail_extra">    dipoleProbabilityInRegion(:,i) = gaussianWeightMatrix * regionOfInterest(i).membershipProbabilityCube(headGrid.insideBrainCube);</div><div class="gmail_extra">    </div><div class="gmail_extra">    % compute centroids of ROIs</div><div class="gmail_extra">    xCube = regionOfInterest(i).headGrid.xCube;</div><div class="gmail_extra">    yCube = regionOfInterest(i).headGrid.yCube;</div><div class="gmail_extra">    zCube = regionOfInterest(i).headGrid.zCube;</div><div class="gmail_extra">    membershipCube = regionOfInterest(i).membershipCube;</div><div class="gmail_extra">    xCentroid = mean(xCube(membershipCube));</div><div class="gmail_extra">    yCentroid = mean(yCube(membershipCube));</div><div class="gmail_extra">    zCentroid = mean(zCube(membershipCube));</div><div class="gmail_extra">    roiCentroids(i,:) = [xCentroid yCentroid zCentroid];</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Force the ROI centroids to be symmetric</div><div class="gmail_extra">leftHemisphereCentroids = roiCentroids(1:2:end,:);</div><div class="gmail_extra">xPositiveLeftHemisphereControids = bsxfun(@times, leftHemisphereCentroids, [-1 1 1]);</div><div class="gmail_extra">meanAbsRoiCentroids = round((xPositiveLeftHemisphereControids+roiCentroids(2:2:end,:))/2);</div><div class="gmail_extra">symmetricRoiCentroids = zeros(size(roiCentroids));</div><div class="gmail_extra">symmetricRoiCentroids(1:2:end,:) = bsxfun(@times, meanAbsRoiCentroids, [-1 1 1]);</div><div class="gmail_extra">symmetricRoiCentroids(2:2:end,:) = meanAbsRoiCentroids;</div><div class="gmail_extra"><br></div><div class="gmail_extra">% generate subject list</div><div class="gmail_extra">fileNameList = {ALLEEG.filename}';</div><div class="gmail_extra"><br></div><div class="gmail_extra">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</div><div class="gmail_extra">%%% Compute dipole pair density (non-normalized) %%%</div><div class="gmail_extra">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</div><div class="gmail_extra">% Calculate dipole densities in source regions and destination regions. Reuse indices from 'from' dipole for 'to' dipole</div><div class="gmail_extra">fromDipoleProbabilityInRegion = zeros(dipolePairAndMeasureObj.from.numberOfDipoles, numberOfRegionsOfInterest);</div><div class="gmail_extra">toDipoleProbabilityInRegion   = zeros(dipolePairAndMeasureObj.to.numberOfDipoles,   numberOfRegionsOfInterest);</div><div class="gmail_extra">[~,~,toIdReverse] = unique(dipolePairAndMeasureObj.toDipoleId, 'stable');</div><div class="gmail_extra">for i = 1:numberOfRegionsOfInterest</div><div class="gmail_extra">    fromDipoleProbabilityInRegion(:,i) = dipoleProbabilityInRegion(fromIdReverse, i);</div><div class="gmail_extra">    toDipoleProbabilityInRegion(:,  i) = dipoleProbabilityInRegion(toIdReverse,   i);</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Prepare dipole pair density by multiplying from-density and to-density. The first dimension is the sum of each subject's IC*IC, the second is (reduced AAL regions)^2==5184.</div><div class="gmail_extra">dipolePairProbabilityOnFromRegionToRegionSubstrate = zeros(dipolePairAndMeasureObj.from.numberOfDipoles, length(includeRoiIdx) * length(includeRoiIdx));</div><div class="gmail_extra">for i=1:dipolePairAndMeasureObj.from.numberOfDipoles</div><div class="gmail_extra">    dipolePairProbabilityOnFromRegionToRegionSubstrate(i, :) = vec(fromDipoleProbabilityInRegion(i,:)' *  toDipoleProbabilityInRegion(i,:))';</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">% Calculate dipole pair density for each unique edge</div><div class="gmail_extra">numberOfsessions = max(dipolePairAndMeasureObj.sessionId); % session means subjects</div><div class="gmail_extra">dipolePairDensity = zeros(size(dipolePairProbabilityOnFromRegionToRegionSubstrate, 2), numberOfsessions);</div><div class="gmail_extra">for i=1:size(dipolePairProbabilityOnFromRegionToRegionSubstrate, 2)</div><div class="gmail_extra">    dipolePairProbabilityOnFromRegionToRegion = dipolePairProbabilityOnFromRegionToRegionSubstrate(:,i);</div><div class="gmail_extra">    sessionDensity = zeros(1,numberOfsessions);</div><div class="gmail_extra">    for j=1:numberOfsessions</div><div class="gmail_extra">        sessionDensity(j) = sum(dipolePairProbabilityOnFromRegionToRegion(dipolePairAndMeasureObj.sessionId == j));</div><div class="gmail_extra">    end</div><div class="gmail_extra">    </div><div class="gmail_extra">    % store dipole pair density</div><div class="gmail_extra">    dipolePairDensity(i,:) = sessionDensity;</div><div class="gmail_extra">end</div><div class="gmail_extra">dipolePairDensity = reshape(dipolePairDensity, [length(includeRoiIdx) length(includeRoiIdx) numberOfsessions]);</div><div class="gmail_extra"><br></div><div class="gmail_extra">% calculate dipole-pair pairwise similarity (could be further optimized by not calculating pair that do not share dipole-pair density in any ROIs)</div><div class="gmail_extra">correlationSimilaity = 1-squareform(pdist(dipolePairAndMeasureObj.linearizedMeasure', 'correlation'));</div><div class="gmail_extra">linearizedMeasureSimilarity = estimate_mutual_information_from_correlation(correlationSimilaity);</div><div class="gmail_extra">    </div><div class="gmail_extra">% save dipolePairDensity and others that is needed for similarity test</div><div class="gmail_extra">save([workingFolder filesep userInputFilename '_dipolePairDensity'], 'dipolePairDensity', 'dipoleProbabilityInRegion', 'roiLabels', 'symmetricRoiCentroids', 'fileNameList')</div><div class="gmail_extra"><br></div><div class="gmail_extra">% save convergenceData</div><div class="gmail_extra">linearizedMeasure = dipolePairAndMeasureObj.linearizedMeasure;</div><div class="gmail_extra">save([workingFolder filesep userInputFilename '_measureConvergence'], 'dipolePairProbabilityOnFromRegionToRegionSubstrate', 'linearizedMeasure', 'linearizedMeasureSimilarity');</div><div class="gmail_extra"><br></div><div class="gmail_extra">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</div><div class="gmail_extra">%%% Generate individual subject's connectivity map--This part is very slow %%%</div><div class="gmail_extra">%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%</div><div class="gmail_extra">% prepare the map</div><div class="gmail_extra">numOfRegionsOfInterest = size(dipolePairDensity,1);</div><div class="gmail_extra">toRegionNumber   = repmat((1:numOfRegionsOfInterest)', [1, numOfRegionsOfInterest]); % first deimension (rows) contains toRegion Numbers.</div><div class="gmail_extra">toRegionNumber   = toRegionNumber(:);</div><div class="gmail_extra">fromRegionNumber = repmat( 1:numOfRegionsOfInterest,   [numOfRegionsOfInterest, 1]); % second deimension (columns) contains fromRegion Numbers.</div><div class="gmail_extra">fromRegionNumber = fromRegionNumber(:);</div><div class="gmail_extra">    % Double check the from and to!!</div><div class="gmail_extra">    % ALLEEG(1,1).CAT.Conn: dims: {'var_to'  'var_from'  'freq'  'time'}</div><div class="gmail_extra">    % figure; imagesc(toRegionNumber); title('To Indices')</div><div class="gmail_extra">    % figure; imagesc(fromRegionNumber); title('From Indices')</div><div class="gmail_extra"><br></div><div class="gmail_extra">if get(handles.rpdcButton,'value')==1</div><div class="gmail_extra">    connectivityType = 'rPDC';</div><div class="gmail_extra">else</div><div class="gmail_extra">    connectivityType = 'dDTF08';</div><div class="gmail_extra">end</div><div class="gmail_extra"><br></div><div class="gmail_extra">for sessionIdx = unique(dipolePairAndMeasureObj.sessionId)'</div><div class="gmail_extra">    effectiveConnectivityTimeFreq = single(zeros(timeFreqSize(1)*timeFreqSize(2), size(dipolePairDensity,1)*size(dipolePairDensity,2)));</div><div class="gmail_extra">    tic</div><div class="gmail_extra">    for fromIdx = 1:max(fromRegionNumber) % up to 72</div><div class="gmail_extra">        for toIdx = 1:max(toRegionNumber) % up to 72</div><div class="gmail_extra">            currentEdgeIdx = find((fromRegionNumber==fromIdx) & (toRegionNumber==toIdx));</div><div class="gmail_extra">            currentSessionIdx = find(dipolePairAndMeasureObj.sessionId==sessionIdx);</div><div class="gmail_extra">            dipolePairDensitiesInRoiPair = dipolePairProbabilityOnFromRegionToRegionSubstrate(currentSessionIdx, currentEdgeIdx);</div><div class="gmail_extra">            </div><div class="gmail_extra">            % 02/10/2016 Makoto. Put it back after discussing with Nima and Scott (during and after my presentation at lab meeting)</div><div class="gmail_extra">            % 12/23/2015 Makoto. Disabled this normalization since this will inflate near-zero values</div><div class="gmail_extra">            normFactor = sum(dipolePairDensitiesInRoiPair);</div><div class="gmail_extra">            dipolePairDensitiesInRoiPair = dipolePairDensitiesInRoiPair / normFactor;</div><div class="gmail_extra">            </div><div class="gmail_extra">            % This is the projected measure</div><div class="gmail_extra">            projectedMeasure = bsxfun(@times, dipolePairAndMeasureObj.linearizedMeasure(currentSessionIdx,:), dipolePairDensitiesInRoiPair);</div><div class="gmail_extra">            effectiveConnectivityTimeFreq(:,currentEdgeIdx) = squeeze(sum(projectedMeasure));</div><div class="gmail_extra">        end</div><div class="gmail_extra">    end</div><div class="gmail_extra">    effectiveConnectivityTimeFreq = single(effectiveConnectivityTimeFreq); % use single to save time and disk space</div><div class="gmail_extra">    effectiveConnectivityTimeFreq = permute(reshape(effectiveConnectivityTimeFreq, timeFreqSize(1), timeFreqSize(2), max(fromRegionNumber), max(fromRegionNumber)), [3 4 1 2]); % Use most consistent dimensions for SIFT and most intuitive for users</div><div class="gmail_extra">    save(sprintf([workingFolder filesep userInputFilename '_%04.f_connectivity'], sessionIdx), 'effectiveConnectivityTimeFreq', 'connectivityType', 'latencies', 'frequencies', 'dimensionLabels', 'fileNameList');</div><div class="gmail_extra">    timeLapse = toc;</div><div class="gmail_extra">    disp(sprintf('%2.0d/%2.0d subjects done (%0.1d sec lapsed)', sessionIdx, length(unique(dipolePairAndMeasureObj.sessionId)), round(timeLapse)));</div><div class="gmail_extra">end</div><div class="gmail_extra">disp('Convert To Anatomical ROI done.')</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Apr 21, 2016 at 2:48 AM, Mohammed Jarjees <span dir="ltr"><<a href="mailto:m.jarjees.1@research.gla.ac.uk" target="_blank">m.jarjees.1@research.gla.ac.uk</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left-width:1px;border-left-color:rgb(204,204,204);border-left-style:solid;padding-left:1ex"><div lang="EN-GB" link="blue" vlink="purple"><div><p class="MsoNormal">Dear Makoto,<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Thank you very much for your quick response. <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Sure, I am going to report this problem in Bugzilla.<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Is there any alternative method to extract the ERP values after MPT clustering or to extract the P values after run statistics by MPT GUI?<u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">About the anatomical regions, do you know how can I do that? <u></u><u></u></p><p class="MsoNormal"><u></u> <u></u></p><p class="MsoNormal">Many Thanks<u></u><u></u></p><p class="MsoNormal">Mohammed<u></u><u></u></p><p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p><p class="MsoNormal"><b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif">From:</span></b><span lang="EN-US" style="font-size:10pt;font-family:Tahoma,sans-serif"> Makoto Miyakoshi [mailto:<a href="mailto:mmiyakoshi@ucsd.edu" target="_blank">mmiyakoshi@ucsd.edu</a>] <br><b>Sent:</b> 21 April 2016 03:38<br><b>To:</b> Mohammed Jarjees<br><b>Cc:</b> <a href="mailto:eeglablist@sccn.ucsd.edu" target="_blank">eeglablist@sccn.ucsd.edu</a><br><b>Subject:</b> Re: [Eeglablist] Extracting ERP values after MPT clustering<u></u><u></u></span></p><div><div class="h5"><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">Dear Mohammed,<u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Sorry to hear the inconvenience. This is a good detailed question. I believe this should be posted for eeglab Bugzilla to be officially registered. Would you mind filing the report here? I appreciate your cooperation and patience.<u></u><u></u></p></div><div><p class="MsoNormal"><a href="https://sccn.ucsd.edu/bugzilla/enter_bug.cgi" target="_blank">https://sccn.ucsd.edu/bugzilla/enter_bug.cgi</a><u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">That being said, I recently noticed that Measure Projection could have a potential problem of double dipping (because you cluster data using ERP, for example, and run statistics on that later). It's probably safer to use anatomical regions, not domains (but that may not be supported by GUI).<u></u><u></u></p></div><div><p class="MsoNormal"><u></u> <u></u></p></div><div><p class="MsoNormal">Makoto<u></u><u></u></p></div></div><div><p class="MsoNormal"><u></u> <u></u></p><div><p class="MsoNormal">On Mon, Apr 18, 2016 at 10:49 AM, Mohammed Jarjees <<a href="mailto:m.jarjees.1@research.gla.ac.uk" target="_blank">m.jarjees.1@research.gla.ac.uk</a>> wrote:<u></u><u></u></p><div><div><p class="MsoNormal">Dear All,<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">I am using  Measure projection toolbox (MPT) to cluster my EEG (ERP) data. In this study I have 3 groups of subjects ( First group has 10 subjects, second group has 9 subjects and third group has 10 subjects) and I have 3 conditions per group. I got 3 domains after MPT clustering. I extracted the ERP values from “sessionConditionCell” for each domains. The size of “sessionConditionCell” is 29*3 (subjects*conditions). I have used the following codes to extract the ERP values and to separate these values for each group and each condition.<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">domainNumber = 1; <span style="color:red">% this should be 1,2 or 3%</span><u></u><u></u></p><p class="MsoNormal">dipoleAndMeasure = STUDY.measureProjection.erp.object; <u></u><u></u></p><p class="MsoNormal">domain                         = STUDY.measureProjection.erp.projection.domain(domainNumber); <u></u><u></u></p><p class="MsoNormal">projection                   = STUDY.measureProjection.erp.projection;<u></u><u></u></p><p class="MsoNormal">headGrid                     = STUDY.measureProjection.erp.headGrid;<u></u><u></u></p><p class="MsoNormal">[linearProjectedMeasure sessionConditionCell groupId uniqeDatasetId dipoleDensity]  = dipoleAndMeasure.getMeanProjectedMeasureForEachSession(headGrid, domain.membershipCube, projection.projectionParameter);<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">for i =1 : 29 ;<u></u><u></u></p><p class="MsoNormal">Condition_1 ( i , : )= sessionConditionCell { i, 1};<u></u><u></u></p><p class="MsoNormal">Condition_2 ( i , : )= sessionConditionCell { i, 2};<u></u><u></u></p><p class="MsoNormal">Condition_3 ( i , : )= sessionConditionCell { i, 3};<u></u><u></u></p><p class="MsoNormal">end<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">Group_1_Condition_1= Condition_1 ( 1:10, : );     Group_2_Condition_1= Condition_1 ( 11:19, : );     Group_3_Condition_1= Condition_1 ( 20:29, : );<u></u><u></u></p><p class="MsoNormal">Group_1_Condition_2= Condition_2 ( 1:10, : );     Group_2_Condition_2= Condition_2 ( 11:19, : );     Group_3_Condition_2= Condition_2 ( 20:29, : );<u></u><u></u></p><p class="MsoNormal">Group_1_Condition_3= Condition_3 ( 1:10, : );     Group_2_Condition_3= Condition_3 ( 11:19, : );     Group_3_Condition_3= Condition_3 ( 20:29, : );<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">When I plotted the average ERP for each condition, each group and each domain, I got different in<b><u> some</u></b> results from the results that I got from MPT GUI. For example the results for group 1 at Domain 1 for 3 conditions are same as the results from MPT GUI as well as the result for domain 2 and all three group and three condition are same as the MPT GUI. However, there are big different for group 2 & 3 at domain 1 as well as group 2 & 3 at domain 3 for all three conditions.<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">Any Suggestion to solve this problem<u></u><u></u></p><p class="MsoNormal"> <u></u><u></u></p><p class="MsoNormal">Best Regards<u></u><u></u></p><p class="MsoNormal"><span style="color:rgb(136,136,136)">Mohammed<u></u><u></u></span></p></div></div><p class="MsoNormal"><br>_______________________________________________<br>Eeglablist page: <a href="http://sccn.ucsd.edu/eeglab/eeglabmail.html" target="_blank">http://sccn.ucsd.edu/eeglab/eeglabmail.html</a><br>To unsubscribe, send an empty email to <a href="mailto:eeglablist-unsubscribe@sccn.ucsd.edu" target="_blank">eeglablist-unsubscribe@sccn.ucsd.edu</a><br>For digest mode, send an email with the subject "set digest mime" to <a href="mailto:eeglablist-request@sccn.ucsd.edu" target="_blank">eeglablist-request@sccn.ucsd.edu</a><u></u><u></u></p></div><p class="MsoNormal"><br><br clear="all"><u></u><u></u></p><div><p class="MsoNormal"><u></u> <u></u></p></div><p class="MsoNormal">-- <u></u><u></u></p><div><div><p class="MsoNormal">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<u></u><u></u></p></div></div></div></div></div></div></div></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature"><div dir="ltr">Makoto Miyakoshi<br>Swartz Center for Computational Neuroscience<br>Institute for Neural Computation, University of California San Diego<br></div></div>
</div></div>