sccn / roiconnect

ROI connectivity analysis in EEG
39 stars 17 forks source link

Format of roi_connect output #5

Closed fpellegrini closed 1 year ago

fpellegrini commented 2 years ago

So far, we get the MIM/MIC/TRGC output here as a vector that contains the connectivity for all indices:

https://github.com/arnodelorme/roiconnect/blob/0de6509af56e2c8257c7df267cfa51c0828fbf1a/pop_roi_connect.m#L130

It would probably nice to have a vec2mat function that takes the vector as input and outputs the connecitivity as a ROIxROIxFrequency matrix. Please see a suggestion here:

function EEG = vec2mat(EEG)

nroi = EEG.roi.nROI;
iinds = 0;
for iroi = 1:nroi
    for jroi = (iroi+1):nroi
        iinds = iinds + 1;
        mim_(iroi, jroi,:) = EEG.roi.MIM(:, iinds);
        mim_(jroi,iroi,:) = mim_(iroi,jroi,:);
        trgc_(iroi,jroi,:) = EEG.roi.TRGC(:,iinds,1) - EEG.roi.TRGC(:,iinds,2);
        trgc_(jroi,iroi,:) = -trgc_(iroi,jroi,:);
    end
end
EEG.roi.MIM_matrix = mim_; 
EEG.roi.TRGC_matrix = trgc_;
fpellegrini commented 2 years ago

EDIT: I now saw that something similar is already included in the plotting function: https://github.com/arnodelorme/roiconnect/blob/0de6509af56e2c8257c7df267cfa51c0828fbf1a/pop_roi_connectplot.m#L328

but I think it would be convenient to also have this matrix format in the EEG struct, overall when doing statistics etc.

arnodelorme commented 2 years ago

Yes, it would be nice to have it in the computation function. I will make the change.

arnodelorme commented 2 years ago

I have added the code e8fd79f However, I am not applying yet the transformation. I am concerned it will mess up the plotting. Always feel free to submit pull request to change the code.