Hi Anam

Sorry for the lag.  mris_left_right_register takes as input surfaces, not the 
overlays or thicknesses.

To flip an overlay file, here is what I would do.  Maybe others can chime in on 
weather this makes sense or if there is an easier way.  

I'd start by running mris_left_right_register.  Then, I would use read_surf.m 
to load in the original, and registered surfaces, eg lh.right and 
lh.sphere.left_right.  Then, I would go through each vertex in lh.right and 
find the corresponding (or closest) vertex in lh.sphere.left_right.  This 
correspondence will define a mapping you could then apply to the overlays.

-Paul

________________________________________
From: Anam Anzak <a.an...@qmul.ac.uk>
Sent: Wednesday, March 15, 2023 3:52 AM
To: Wighton, Paul; Freesurfer@nmr.mgh.harvard.edu
Cc: Bernardo Pimentel
Subject: Re: Flipping Thickness Matrices

        External Email - Use Caution

Dear Paul,

Thank you for your reply! Just one thing we haven't really figured out... does 
mris_left_right_register take as input the thickness (mgh) files or the 
surfaces? I've been trying but can't really apply it to the thickness files. In 
theory, we would really just like to flip the thickness matrix right->left... 
is mris_left_right_register something we should apply upstream of the thickness 
file generation?

Thank you and all the best,
Bernardo and Anam

--
Bernardo Pimentel
Neurology Resident
Department of Neurology - Christian-Doppler University Hospital
Paracelsus Medical University
Salzburg, Austria

Miss Anam Anzak MBBS PhD MRCS PGCCE
NIHR Clinical Lecturer (Neurosurgery)
Specialty Registrar in Neurosurgery, London deanery
________________________________
From: freesurfer-boun...@nmr.mgh.harvard.edu 
<freesurfer-boun...@nmr.mgh.harvard.edu> on behalf of Wighton, Paul 
<pwigh...@mgh.harvard.edu>
Sent: 07 March 2023 21:31
To: Freesurfer@nmr.mgh.harvard.edu <Freesurfer@nmr.mgh.harvard.edu>
Cc: Bernardo Pimentel <bcpimente...@gmail.com>
Subject: Re: [Freesurfer] Flipping Thickness Matrices

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<https://secure-web.cisco.com/1IwEg4Ngb-r-J1t-vbpx7YHZQj0wpI3pm8yDOxlEsVPbG9aHMjST1Zv4dmfGDlKw8xL5o8GYkytU3ISu0F5HlXjONh2LzdtmgzKFJ0WwnLXHfA18XsLx4iMYbDiteSBCazkrtdTg7f25v5HZ7xfz8XNdZ7ka2CRQQqGNvMDf2EEHXqV2DNYIAL6pRWufQVVNmDXI1YuhcaLz27rpi_1yWgrPozQc5QxAxSi4KOTMLWdE4wcAACPJhgG8TI2cXlEP0reXb7KKBFSpCJoJ1rb7NyeaNTztnK06U7f0rxM4ZY8ax2ZYJRPjygatZbyMQ4pvA/https%3A%2F%2Fgithub.com%2Ffreesurfer%2Ffreesurfer%2Fblob%2Fdev%2Fmris_left_right_register%2Fmris_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<https://secure-web.cisco.com/1UauhTONyxBc7oVfaVw3W8BQtu4LVoWJL5HsU9yjr4JuruAhUef8g8GKoxKM2kTdB65eEPY6RE85V3xeIOiky6TpyPwilG1s-wCN8x3qQ4j9ku2x-P88a3zaY-x08GPqyfx-slO9ygw159WcPCB372nOZk--kTY6puAzSO6oGSaPqRk3yNHVUMfXX8o_YzalZksNe88_oOHB1kDK_6ZQ3vr48Br7Q31PvUWLQcKy1kArnoOKQnUEGWrk07Tba6vs4gj0UoMmE47yFiLqWrjScBJ5DvlqlitGb9eGDwVdgJ5sFto3gu9wDHkjO1HUdR7yW/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Ffreesurfer>
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://secure-web.cisco.com/1gPhj8Cfs9RCrFNCmf-mD1i9Gr-4VHwpBOI3Cv9mF4EiWNzoAeON-vj7DFL0sNB7OlnnHgvAJ_a3yifmGCWNHxkD9BSrIGP7cmRvuDNEmrHl5BnT6w1mwH6NBQ4P4yq8X4PS3GTVGZwfH3CQTCA7R_SDkcZoiU6ROTNAycuDTddFxgubhBG_YY0oEgnhjzmgg_YmqhisGIlQiVhTFnyU9BQWcuHbk6HsM3vlnjiIrdepR_pLM1ZqKaNAVsxD8Qt-b-qWd0N-v8-KJgtwviglKqSI7m4bJB-UjPXD4qpn5pVK2Qee16ldYyYCaW2J9BADt/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline>
 
<https://www.massgeneralbrigham.org/complianceline<https://secure-web.cisco.com/1gPhj8Cfs9RCrFNCmf-mD1i9Gr-4VHwpBOI3Cv9mF4EiWNzoAeON-vj7DFL0sNB7OlnnHgvAJ_a3yifmGCWNHxkD9BSrIGP7cmRvuDNEmrHl5BnT6w1mwH6NBQ4P4yq8X4PS3GTVGZwfH3CQTCA7R_SDkcZoiU6ROTNAycuDTddFxgubhBG_YY0oEgnhjzmgg_YmqhisGIlQiVhTF
 
nyU9BQWcuHbk6HsM3vlnjiIrdepR_pLM1ZqKaNAVsxD8Qt-b-qWd0N-v8-KJgtwviglKqSI7m4bJB-UjPXD4qpn5pVK2Qee16ldYyYCaW2J9BADt/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline>>
 .
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.


_______________________________________________
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. 

Reply via email to