Re: [Freesurfer] Brain in a Box

2024-06-20 Thread Douglas N. Greve

You can also use mri_mask, eg, after running synthstrip, eg
mri_mask -bb 0 stripped.mgz stripped.mgz stripped.crop.mgz
-bb 0 means to create a tight (0) fitting bounding box around the 
non-zero voxels. The output stripped.crop.mgz will be the cropped output


On 6/18/2024 11:00 AM, Huang, Yujing wrote:


Hi Hebah,

You don’t need to install Surfa separately. It is part of your 
Freesurfer installation. Surfa Volume takes .mgz/.mgh, .nii/.nii.gz 
formats.


Once you sourced your Freesurfer environment, use ‘fspython’ to access 
the Python distribution shipped with your Freesurfer.


https://surfer.nmr.mgh.harvard.edu/fswiki/SetupConfiguration_Mac

https://surfer.nmr.mgh.harvard.edu/fswiki/SetupConfiguration_Linux

What I showed in previous message was from an interactive fspython 
session. You can write your own python scripts to use Surfa. On Surfa 
github, there are some documentations on how to use the library. In 
your sourced Freesurfer environment, use ‘fspython’ to run your scripts.


Best,

Yujing

*From:*Hebah Tanveer 
*Sent:* Tuesday, June 18, 2024 10:32 AM
*To:* Huang, Yujing 
*Subject:* Re: [Freesurfer] Brain in a Box

*External Email - Use Caution *

Hi, Yujing! I am new to the field of neuroimaging and want to better 
understand how to run Surfa. I'll need to install Python+IDE, C+IDE, 
and then run pip install surfa in my computer's command window? What 
is the file format of the slice images that Surfa will intake?



/Best,
/*Hebah*

On Tue, Jun 18, 2024 at 7:26 AM Huang, Yujing 
 wrote:


I'm wondering if the bbox() implementation in Surfa
(https://github.com/freesurfer/surfa/tree/master) will achieve the
task?

surfa.image.framed.bbox()
(https://github.com/freesurfer/surfa/blob/master/surfa/image/framed.py#L203)
computes the bounding box of the image data greater than zero.

I tried it on bert orig.mgz,

>>> import surfa as sf
>>> bert='/usr/local/freesurfer/dev/subjects/bert/mri/orig.mgz'
>>> vol=sf.load_volume(bert)
>>> vol
sf.Volume(shape=(256, 256, 256), dtype=uint8)
>>> vol.shape
(256, 256, 256)
>>> bbox=vol.bbox()
>>> bbox
(slice(47, 207, None), slice(3, 255, None), slice(3, 252, None))


Yujing

-Original Message-
From: freesurfer-boun...@nmr.mgh.harvard.edu
 On Behalf Of Wighton, Paul
    Sent: Monday, June 17, 2024 5:34 PM
To: Freesurfer support list 
Subject: Re: [Freesurfer] Brain in a Box

Hi Hebah,

Interesting application.  You could try running mri_synthstrip
then analyse the resulting binary mask to determine the first and
last slices in each direction.

-Paul


From: freesurfer-boun...@nmr.mgh.harvard.edu
 on behalf of Hebah
Tanveer 
Sent: Monday, June 17, 2024 5:18 PM
To: freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] Brain in a Box

        External Email - Use Caution

I'm trying to determine the smallest rectangular prism that a
brain will fit in based on its MRI scan. My strategy is as
follows: I am moving through the brain axially, sagittally, and
coronally to see where the brain "starts" appearing and "stops"
appearing. Then, I'm subtracting the amount of no-brain slices
from the total number of slices and multiplying the result by the
slice thickness.

This should get me the length (sagittal plane), width (coronal
plane), and height (axial plane) of a box that contains the brain.

Is there a function within FreeSurfer that can automate this
process of determining "first and last sight of brain" ? It is
quite time consuming to manually check hundreds of patients!

Best,
Hebah


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

___
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 o

Re: [Freesurfer] Brain in a Box

2024-06-18 Thread Huang, Yujing
Hi Hebah,

You don’t need to install Surfa separately. It is part of your Freesurfer 
installation. Surfa Volume takes .mgz/.mgh, .nii/.nii.gz formats.

Once you sourced your Freesurfer environment, use ‘fspython’ to access the 
Python distribution shipped with your Freesurfer.
https://surfer.nmr.mgh.harvard.edu/fswiki/SetupConfiguration_Mac
https://surfer.nmr.mgh.harvard.edu/fswiki/SetupConfiguration_Linux

What I showed in previous message was from an interactive fspython session. You 
can write your own python scripts to use Surfa. On Surfa github, there are some 
documentations on how to use the library. In your sourced Freesurfer 
environment, use ‘fspython’ to run your scripts.

Best,

Yujing


From: Hebah Tanveer 
Sent: Tuesday, June 18, 2024 10:32 AM
To: Huang, Yujing 
Subject: Re: [Freesurfer] Brain in a Box


External Email - Use Caution
Hi, Yujing! I am new to the field of neuroimaging and want to better understand 
how to run Surfa. I'll need to install Python+IDE, C+IDE, and then run pip 
install surfa in my computer's command window? What is the file format of the 
slice images that Surfa will intake?

Best,
Hebah


On Tue, Jun 18, 2024 at 7:26 AM Huang, Yujing 
mailto:yhuan...@mgh.harvard.edu>> wrote:
I'm wondering if the bbox() implementation in Surfa 
(https://github.com/freesurfer/surfa/tree/master) will achieve the task?

surfa.image.framed.bbox() 
(https://github.com/freesurfer/surfa/blob/master/surfa/image/framed.py#L203)  
computes the bounding box of the image data greater than zero.

I tried it on bert orig.mgz,

>>> import surfa as sf
>>> bert='/usr/local/freesurfer/dev/subjects/bert/mri/orig.mgz'
>>> vol=sf.load_volume(bert)
>>> vol
sf.Volume(shape=(256, 256, 256), dtype=uint8)
>>> vol.shape
(256, 256, 256)
>>> bbox=vol.bbox()
>>> bbox
(slice(47, 207, None), slice(3, 255, None), slice(3, 252, None))


Yujing

-Original Message-
From: 
freesurfer-boun...@nmr.mgh.harvard.edu<mailto:freesurfer-boun...@nmr.mgh.harvard.edu>
 
mailto:freesurfer-boun...@nmr.mgh.harvard.edu>>
 On Behalf Of Wighton, Paul
Sent: Monday, June 17, 2024 5:34 PM
To: Freesurfer support list 
mailto:freesurfer@nmr.mgh.harvard.edu>>
Subject: Re: [Freesurfer] Brain in a Box

Hi Hebah,

Interesting application.  You could try running mri_synthstrip then analyse the 
resulting binary mask to determine the first and last slices in each direction.

-Paul


From: 
freesurfer-boun...@nmr.mgh.harvard.edu<mailto:freesurfer-boun...@nmr.mgh.harvard.edu>
 
mailto:freesurfer-boun...@nmr.mgh.harvard.edu>>
 on behalf of Hebah Tanveer 
mailto:hebah.tanv...@biotexmedical.com>>
Sent: Monday, June 17, 2024 5:18 PM
To: freesurfer@nmr.mgh.harvard.edu<mailto:freesurfer@nmr.mgh.harvard.edu>
Subject: [Freesurfer] Brain in a Box

External Email - Use Caution

I'm trying to determine the smallest rectangular prism that a brain will fit in 
based on its MRI scan. My strategy is as follows: I am moving through the brain 
axially, sagittally, and coronally to see where the brain "starts" appearing 
and "stops" appearing. Then, I'm subtracting the amount of no-brain slices from 
the total number of slices and multiplying the result by the slice thickness.

This should get me the length (sagittal plane), width (coronal plane), and 
height (axial plane) of a box that contains the brain.

Is there a function within FreeSurfer that can automate this process of 
determining "first and last sight of brain" ? It is quite time consuming to 
manually check hundreds of patients!

Best,
Hebah


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto:Freesurfer@nmr.mgh.harvard.edu>
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu<mailto: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.
___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
ht

Re: [Freesurfer] Brain in a Box

2024-06-18 Thread Huang, Yujing
I'm wondering if the bbox() implementation in Surfa 
(https://github.com/freesurfer/surfa/tree/master) will achieve the task?

surfa.image.framed.bbox() 
(https://github.com/freesurfer/surfa/blob/master/surfa/image/framed.py#L203)  
computes the bounding box of the image data greater than zero.

I tried it on bert orig.mgz, 

>>> import surfa as sf
>>> bert='/usr/local/freesurfer/dev/subjects/bert/mri/orig.mgz'
>>> vol=sf.load_volume(bert)
>>> vol
sf.Volume(shape=(256, 256, 256), dtype=uint8)
>>> vol.shape
(256, 256, 256)
>>> bbox=vol.bbox()
>>> bbox
(slice(47, 207, None), slice(3, 255, None), slice(3, 252, None))


Yujing

-Original Message-
From: freesurfer-boun...@nmr.mgh.harvard.edu 
 On Behalf Of Wighton, Paul
Sent: Monday, June 17, 2024 5:34 PM
To: Freesurfer support list 
Subject: Re: [Freesurfer] Brain in a Box

Hi Hebah,

Interesting application.  You could try running mri_synthstrip then analyse the 
resulting binary mask to determine the first and last slices in each direction.

-Paul


From: freesurfer-boun...@nmr.mgh.harvard.edu 
 on behalf of Hebah Tanveer 

Sent: Monday, June 17, 2024 5:18 PM
To: freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] Brain in a Box

External Email - Use Caution

I'm trying to determine the smallest rectangular prism that a brain will fit in 
based on its MRI scan. My strategy is as follows: I am moving through the brain 
axially, sagittally, and coronally to see where the brain "starts" appearing 
and "stops" appearing. Then, I'm subtracting the amount of no-brain slices from 
the total number of slices and multiplying the result by the slice thickness.

This should get me the length (sagittal plane), width (coronal plane), and 
height (axial plane) of a box that contains the brain.

Is there a function within FreeSurfer that can automate this process of 
determining "first and last sight of brain" ? It is quite time consuming to 
manually check hundreds of patients!

Best,
Hebah


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer

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



Re: [Freesurfer] Brain in a Box

2024-06-17 Thread Wighton, Paul
Hi Hebah,

Interesting application.  You could try running mri_synthstrip then analyse the 
resulting binary mask to determine the first and last slices in each direction.

-Paul


From: freesurfer-boun...@nmr.mgh.harvard.edu 
 on behalf of Hebah Tanveer 

Sent: Monday, June 17, 2024 5:18 PM
To: freesurfer@nmr.mgh.harvard.edu
Subject: [Freesurfer] Brain in a Box

External Email - Use Caution

I'm trying to determine the smallest rectangular prism that a brain will fit in 
based on its MRI scan. My strategy is as follows: I am moving through the brain 
axially, sagittally, and coronally to see where the brain "starts" appearing 
and "stops" appearing. Then, I'm subtracting the amount of no-brain slices from 
the total number of slices and multiplying the result by the slice thickness.

This should get me the length (sagittal plane), width (coronal plane), and 
height (axial plane) of a box that contains the brain.

Is there a function within FreeSurfer that can automate this process of 
determining "first and last sight of brain" ? It is quite time consuming to 
manually check hundreds of patients!

Best,
Hebah


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



[Freesurfer] Brain in a Box

2024-06-17 Thread Hebah Tanveer
External Email - Use Caution

I'm trying to determine the smallest rectangular prism that a brain will
fit in based on its MRI scan. My strategy is as follows: I am moving
through the brain axially, sagittally, and coronally to see where the brain
"starts" appearing and "stops" appearing. Then, I'm subtracting the amount
of no-brain slices from the total number of slices and multiplying the
result by the slice thickness.

This should get me the length (sagittal plane), width (coronal plane), and
height (axial plane) of a box that contains the brain.

Is there a function within FreeSurfer that can automate this process of
determining "first and last sight of brain" ? It is quite time consuming to
manually check hundreds of patients!

Best,
Hebah
___
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 
 .
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.