Hi Anam, Check out mris_left_right_register. It's not super well documented, but it takes as input the right and left hemispheres, inflated onto a sphere, and outputs the left hemisphere registered to the right and the right hemisphere registered to the left, also inflated onto a sphere.
If you'd like to do this in matlab, perhaps looking at the code for mris_left_right_regsiter would help https://github.com/freesurfer/freesurfer/blob/dev/mris_left_right_register/mris_left_right_register.cpp -Paul ________________________________________ From: freesurfer-boun...@nmr.mgh.harvard.edu <freesurfer-boun...@nmr.mgh.harvard.edu> on behalf of Anam Anzak <a.an...@qmul.ac.uk> Sent: Tuesday, March 7, 2023 4:00 PM To: Freesurfer@nmr.mgh.harvard.edu Cc: Bernardo Pimentel Subject: [Freesurfer] Flipping Thickness Matrices External Email - Use Caution Dear FreeSurfer Community, Has anyone had any success with solving the below problem: I am dealing with brain lesions which may present on the left or right hemisphere of the brain. 1. I wish to 'FLIP' RIGHT sided hemispheres (which contain lesions) to the LEFT side, so I ultimately can collate all my data and analyse brain hemispheres that are IPSILATERAL or CONTRALATERAL to the side of the brain lesion. 2. When I use the Flip function below, the matrix generated seems to be correct, HOWEVER the subsequent IMAGE generated from the matrix, appears incorrect (it is not at all a mirror image of the original image). 3. NOTE: My matrices include a Lesion Mask and a Medial Wall Mask (I am interested in examining Cortical Thickness values of all the cortex EXCEPT the lesion and medial wall (tentorium and ventricles etc). Here are the commands used, for eg. 'subject 1': %% 4b. Load the binary Lesion masks RIGHT right_lesion_filelist = strcat(P, '/Oedema_masks_bin/', Imaging_Code, '_rh_fsaverage5_bin.mgh'); % load RIGHT lesion masks into a matrix right_lesions = SurfStatReadData([right_lesion_filelist]); right_lesions = ~right_lesions; % create a left hemisphere matrix filled with 1s left_hemisphere = ones(17,10242) % concatenate horizontally lesions masks (L) with right hemisphere matrix fullbrain_with_right_lesions = horzcat(left_hemisphere, right_lesions) % create medial wall mask for all subjects r_whole_mask = repmat(mask, 17, 1) % add the medial wall mask on the lesion masks fullbrain_lesion_medialwall = fullbrain_with_right_lesions.*r_whole_mask % apply matrix with lesion & medial wall to the thickness values T_right = fullbrain_lesion_medialwall .* T_rightlesion %% Flip the Right sided images to the left % reverse the element in each row subject1 = T_right(1,:) SurfStatView(subject1, SP) SP = SurfStatAvSurf({[P '/fsaverage5/surf/rh.pial'],[P '/fsaverage5/surf/lh.pial']}) subject1_flipped = fliplr(subject1) SurfStatView(subject1_flipped, SP) mirror_image = fliplr(T_right) SurfStatView(mirror_image(1,:), SP) Any thoughts would be very much appreciated! Kind regards Anam Miss Anam Anzak MBBS PhD MRCS PGCCE NIHR Clinical Lecturer (Neurosurgery) Specialty Registrar in Neurosurgery, London deanery _______________________________________________ Freesurfer mailing list Freesurfer@nmr.mgh.harvard.edu https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer The information in this e-mail is intended only for the person to whom it is addressed. If you believe this e-mail was sent to you in error and the e-mail contains patient information, please contact the Mass General Brigham Compliance HelpLine at https://www.massgeneralbrigham.org/complianceline <https://www.massgeneralbrigham.org/complianceline> . Please note that this e-mail is not secure (encrypted). If you do not wish to continue communication over unencrypted e-mail, please notify the sender of this message immediately. Continuing to send or respond to e-mail after receiving this message means you understand and accept this risk and wish to continue to communicate over unencrypted e-mail.