Re: [Freesurfer] Help with group analysis

2022-09-25 Thread Douglas N. Greve
look at the fsgd examples to see if any fit your situation. Note that 
the input needs to be something like

Input    310211    LR 1    15,5    2,678785    645292,6651 152275,2
ie, "LR" instead of "1", etc
using commas (,) instead of points (.) may cause problems

On 9/25/2022 1:10 PM, fernanda rohrsetzer wrote:


External Email - Use Caution

I'm sorry!

attached the FSGD file.

Em dom., 25 de set. de 2022 às 14:10, Douglas N. Greve 
 escreveu:


no fsgd file was attached. Also, have you looked at *MailScanner
has detected a possible fraud attempt from "secure-web.cisco.com"
claiming to be*
https://surfer.nmr.mgh.harvard.edu/fswiki/FsgdExamples


?

On 9/23/2022 10:04 AM, fernanda rohrsetzer wrote:


External Email - Use Caution

Hi Freesufer's,
I need to run a group analysis but I don't know how to do it, the
error always appears (print below). There are 3 groups (
risk_group) that I would like to insert as a class (LR = level 1,
HR = level 2 and MDD = level 3) and I would like to control for
sex, age and total brain measure. Please, if anyone can help me
understand what I'm doing wrong, I'd really appreciate it.
The FSG file is attached
Thank you.


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
*MailScanner has detected a possible fraud attempt from
"secure-web.cisco.com" claiming to be*
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer  



___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
*MailScanner has detected a possible fraud attempt from
"secure-web.cisco.com" claiming to be*
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
*MailScanner has detected a possible fraud attempt from
"secure-web.cisco.com" claiming to be*
https://www.massgeneralbrigham.org/complianceline


<*MailScanner has detected a possible fraud attempt from
"secure-web.cisco.com" claiming to be*
https://www.massgeneralbrigham.org/complianceline

>
.


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

Re: [Freesurfer] Help with group analysis

2022-09-25 Thread fernanda rohrsetzer
External Email - Use Caution

I'm sorry!

attached the FSGD file.

Em dom., 25 de set. de 2022 às 14:10, Douglas N. Greve <
dgr...@mgh.harvard.edu> escreveu:

> no fsgd file was attached. Also, have you looked at
> https://secure-web.cisco.com/1xDB2MdU7IttZMHh8Wcpy-H4rASI2uqj9-MUHGYt5B5AJhCMmszuKV-viLm47WoU7jm403uKh8mLzeA5xcxQoHZQvsbwcGRWH_ptuX-KXJvDiLaUftl-V1VX6CaHAJNGvDardNN7ga4LKaOP2jpFCH5OG_MBWK71pE00hp5FfRsl5tvuqGeGgetChB4DtXaaEVBwBotJ0slybBFLiZSpKXjmQdl23gdAdN5B0aCJoCDC6yWZKkKkeyzIjf6Ami-wCFlRhMjMz90U_NRs0kpqyZIYvJyQ7a_cWmtIXnsRvMhGLkoGgd9tnwE_xwF_aMu_IkvPfBIn6udwK6L9TVjH0sg/https%3A%2F%2Fsurfer.nmr.mgh.harvard.edu%2Ffswiki%2FFsgdExamples
>  ?
>
> On 9/23/2022 10:04 AM, fernanda rohrsetzer wrote:
>
> External Email - Use Caution
> Hi Freesufer's,
> I need to run a group analysis but I don't know how to do it, the error
> always appears (print below). There are 3 groups ( risk_group) that I would
> like to insert as a class (LR = level 1, HR = level 2 and MDD = level 3)
> and I would like to control for sex, age and total brain measure. Please,
> if anyone can help me understand what I'm doing wrong, I'd really
> appreciate it.
> The FSG file is attached
> Thank you.
>
>
> ___
> Freesurfer mailing 
> listfreesur...@nmr.mgh.harvard.eduhttps://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
>
>
> ___
> Freesurfer mailing list
> Freesurfer@nmr.mgh.harvard.edu
> https://secure-web.cisco.com/1IeS-YL57fzD75MFwwJjA4Sd-7EvX1tlEDghimEHC83PSTZvOaTC6uMGX0MeKlQyTBAimu2DAS98JjAF8rUFAl4eqOG6dAf7DEn9gcnJBQHi7SP8IEjsZrRwbLwfrSOrB4YuKj5JI2j33_LzbO1F75s57wSnEOwgZfit1pTGvtxmDV7iW1wC3FgMxsbk2pZv4Spl1fejTSoTqEdq3IbqUp0br17fLku3me34G20-zVPj6aWecGr4KglnFxOwqfw_g7hoiai7AAwAjveXLBWwL2KQV9IzCL6pLWYPBKbkp_yGV4zQXb15sB4G3WqfLw0smntAbzCh6ZUgoaNxkgrmbiA/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://secure-web.cisco.com/1lcJ8l8iGsr8svtwqrjcj_YgzO3i4H8osHsQ5MG8o0gSMDmRRUaO02v2siHGL8OJH267EE9rpCJqbHmHeNA2dwDDSYVshI1edCUdw4LQVNdg79MFK7K-hG_m9DSFxk8k4hygrTLezzCgQmakGharcc-FhM6ResORxNNnrX1i0o-P7hJlCk6yBnFeO8G_Om_p-WARUc7EI69ecntT_HF1Pf8o6onpEAWphxwHOeUOjmNjisaQQcB7SwSbhbkp2fZShDqx3TNXAiJUDQyKAaksfscnnb9bpS2-pKhxR1i-NnFejBc0Plkhqxk8X6yb23Fkwd8ftpb22qjX5Eg7_tBHnRg/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline
>  <
> https://secure-web.cisco.com/1lcJ8l8iGsr8svtwqrjcj_YgzO3i4H8osHsQ5MG8o0gSMDmRRUaO02v2siHGL8OJH267EE9rpCJqbHmHeNA2dwDDSYVshI1edCUdw4LQVNdg79MFK7K-hG_m9DSFxk8k4hygrTLezzCgQmakGharcc-FhM6ResORxNNnrX1i0o-P7hJlCk6yBnFeO8G_Om_p-WARUc7EI69ecntT_HF1Pf8o6onpEAWphxwHOeUOjmNjisaQQcB7SwSbhbkp2fZShDqx3TNXAiJUDQyKAaksfscnnb9bpS2-pKhxR1i-NnFejBc0Plkhqxk8X6yb23Fkwd8ftpb22qjX5Eg7_tBHnRg/https%3A%2F%2Fwww.massgeneralbrigham.org%2Fcomplianceline>
>  .
>


w0_group.fsgd 
Description: Binary data
___
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. 


Re: [Freesurfer] confirmation of processes/commands used in full processing pipeline

2022-09-25 Thread Douglas N. Greve



On 9/20/2022 5:01 PM, Harriott, Emily M wrote:


External Email - Use Caution

Dear FreeSurfer experts,

I hope this email finds you all doing well. I'm a second-year doctoral 
student (and beginner FreeSurfer user) trying to use FreeSurfer to 
segment gray and white matter in 90 T1 images of children/adolescents 
(with reading disorders, Neurofibromatosis type 1, and typically 
developing) for a project; I have two questions about processing these 
images, and I would be so very grateful to receive some 
thoughts/suggestions/advice etc. from some FreeSurfer experts such as 
yourselves.
I ran recon-all on each of those 90 images, but one single run of 
recon-all left too much dura in the gray matter segmentation and too 
much white matter out of the white matter segmentation (the amount of 
white matter left out varied depending on the intensity contrast of 
each image). To fix the dura/gray matter issue, I re-ran recon-all 
using the -gcut flag and edited out by hand the remaining dura; this 
seemed to help. To fix the white matter issue, I tried adding control 
points and adding white matter voxels and re-running recon-all; this 
unfortunately did not seem to help, as control points led to worse 
segmentation and the added white matter voxels had minimal to no effect.
So, after some experimentation, I have created a full processing 
pipeline to use on my data.But, before I apply it to all 90 images, I 
wanted to confirm with you all experts that this will 1) work and 2) 
do what I want it to do.


Question 1: If I process my data in FS 7.2.0, can I go back and 
analyze it using QDEC in FS 6.0.0? Or do I have to process it in 6.0.0 
to use QDEC?
Yes, that is  fine,  though keep in mind that we are not supporting qdec 
any more.


Question 2: Here is my pipeline (see below). Will this work? Will it 
do what I want it to do? Do you have any suggestions? I'm a beginner; 
is there anything I should be careful of or watch out for that I don't 
know about? After some experimentation on a subsample, this pipeline 
appears to work, but I really want to ensure it is doing what I want 
it to do and will do that consistently.
I did not follow your pipeline description entirely. What you have below 
looks like it will do what you want it to do, but I'd change a few 
things. First, you need to add -autorecon3 so that it completes the 
process. You can also use -autorecon2-cp instead of -autorecon2 (this 
will skip the most time consuming part). Finally, I would not run 
-qcache until after you are satisfied with the results (you can/should 
run recon-all with just the -qcache flag)



For one subject

I first run the initial recon-all (with some flags).
/$recon-all -i  -s  -sd  -wsthresh 
10 -gcut -qcache/


Next, I open brainmask.mgz in FreeView and edit out the remaining dura 
mater by hand. When I save this new brainmask.mgz, I overwrite the old 
brainmask.mgz with this new edited brainmask.mgz.


I then run multiple second iterations of recon-all, allowing me to use 
different seg-wlo thresholds (seg-wlo thresholds of 40, 50, 60, 70, 
80, 90 are applied to each image).

The multiple second iterations of recon-all are:
/$recon-all autorecon2 -s  -sd  -seg-wlo 90 -qcache/
/$/recon-all autorecon2 -s  -sd/  -seg-wlo 80 
-qcache/
//$/recon-all autorecon2 -s  -sd/  -seg-wlo 70 
-qcache/

/
//$/recon-all autorecon2 -s  -sd / -seg-wlo 60 
-qcache/

/
$/recon-all autorecon2 -s  -sd/  -seg-wlo 50 
-qcache//

//
$/recon-all autorecon2 -s  -sd/ -seg-wlo 
40 -qcache


(Note that I have 6 distinct subjects_?0 folders for 6 distinct 
seg-wlo values)


In FreeView, I then visually assess the image/segmentation produced by 
each seg-wlo threshold to select the threshold that most optimally 
segmented the gray and white matter. I save the subject folder with 
the optimal seg-wlo threshold, as determined visually in FreeView by 
me, to a new subjects directory; this new subjects directory's folder 
is specified "SELECT".


I now have measures of cortical thickness, surface area, and volume, 
but I also want measures of local gyrification index (LGI).
With MATLAB 2022a active (I'm working on a large computing cluster, so 
I have to activate MATLAB/2022a as a module), I run the LGI recon-all.

/$recon-all -s  -sd  -localGI -qcache/
/
/
I then obtain the measurements of LGI. To run this line, I also have a 
.bashrc file in my subjects_SELECT folder that has one line: MEASURE1 
= pial_lgi.

/$recon-all -s  -sd  -measure pial_lgi -qcache/

Then the data go into QDEC and I should be able to analyze from there.

Any confirmations/denials, suggestions, or advice you all have would 
be so very greatly appreciated.



Thank you so very much!
Emily Harriott
Doctoral Student, Vanderbilt University
Nashville, TN


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

Re: [Freesurfer] Help with group analysis

2022-09-25 Thread Douglas N. Greve
no fsgd file was attached. Also, have you looked at 
https://surfer.nmr.mgh.harvard.edu/fswiki/FsgdExamples ?


On 9/23/2022 10:04 AM, fernanda rohrsetzer wrote:


External Email - Use Caution

Hi Freesufer's,
I need to run a group analysis but I don't know how to do it, the 
error always appears (print below). There are 3 groups ( risk_group) 
that I would like to insert as a class (LR = level 1, HR = level 2 and 
MDD = level 3) and I would like to control for sex, age and total 
brain measure. Please, if anyone can help me understand what I'm doing 
wrong, I'd really appreciate it.

The FSG file is attached
Thank you.


___
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 
 .
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] White matter normalization of FLAIR images

2022-09-25 Thread Douglas N. Greve
it looks like you are using v6. In v6, the flair might not have been 
normalized


On 9/23/2022 3:53 PM, Fischl, Bruce R.,PHD wrote:
I think you need to add something like -FLAIRpial or -T2pial so it 
uses it (in which case it will first normalize it), but hopefully 
someone else can confirm


cheers
Bruce

*From:* freesurfer-boun...@nmr.mgh.harvard.edu 
 on behalf of James Brown 


*Sent:* Friday, September 23, 2022 2:40 PM
*To:* freesurfer@nmr.mgh.harvard.edu 
*Subject:* Re: [Freesurfer] White matter normalization of FLAIR images

External Email - Use Caution

Dear Dr Bruce,
Thank you very much for your guidance.
I ran recon-all on a subject "test" using Freesurfer V6.0 and the 
following command line is reported in the "recon-all.log":


/usr/local/freesurfer/6.0/bin/recon-all -all -qcache -i T1.nii.gz 
-flair FLAIR.nii.gz -s test


When I search for normalization of flair, I only find how Freesurfer 
normalized T1.
I searched for "nonmax_suppress" and it is not in the log file. I am 
just wondering what I am doing wrong. Thanks again for any 
highlights about the correct method to normalize FLAIR


Sincerely,



Hi JamesB

there is T2/FLAIR normalization in recon-all if you process it through 
there. You can look for "nonmax_suppress" if you want to find the 
command line


cheers
Bruce

On Fri, Sep 23, 2022 at 2:06 PM James Brown  wrote:

Dear Freesurfer experts,
We appreciate any advice or guidance from your community of
professionals and experts in the field about the issue below.

Thank you for your kindness.

Dear Freesurfer experts,
In order to normalize white matter intensity of T1 images and
correct for bias field. We do the following steps:
mri_convert T1.nii.gz T1.mgz
mri_nu_correct.mni --i T1.mgz --o T1_N3.mgz --n 2
mri_normalize -g 1 T1_N3.mgzT1_norm.mgz
mri_convert T1_norm.mgz T1_norm.nii.gz

We would like to apply bias field correction on FLAIR images then
normalize white matter intensity.
We tried N4biasfieldcorrection from ANTS but it didn't work as
expected. Reviewing documents about N4biasfieldcorrection we
realize that the algorithm has been developed to correct bias
field correction in T1 not clear if it works on FLAIR images.

Are the steps above valid for normalizing FLAIR images or can it
only be applied on T1 images? I would like to send a
"recon-all.log" file that includes the processing steps of FLAIR.
Is there any link I can use to upload the file. It gets rejected
every time I send it due to size limitations.

We appreciate any feedback about the proper way to correct FLAIR
images for bias fields and normalize white matter intensity in
FLAIR images.

Thank you
JamesB

On Wed, Sep 21, 2022 at 10:18 AM James Brown 
wrote:

Dear Freesurfer experts,
In order to normalize white matter intensity of T1 images and
correct for bias field. We do the following steps:
mri_convert T1.nii.gz T1.mgz
mri_nu_correct.mni --i T1.mgz --o T1_N3.mgz --n 2
mri_normalize -g 1 T1_N3.mgzT1_norm.mgz
mri_convert T1_norm.mgz T1_norm.nii.gz

We would like to apply bias field correction on FLAIR images
then normalize white matter intensity.
We tried N4biasfieldcorrection from ANTS but it didn't work as
expected. Reviewing documents about N4biasfieldcorrection we
realize that the algorithm has been developed to correct bias
field correction in T1 not clear if it works on FLAIR images.

Are the steps above valid for normalizing FLAIR images or can
it only be applied on T1 images? I would like to send a
"recon-all.log" file that includes the processing steps of
FLAIR. Is there any link I can use to upload the file. It gets
rejected every time I send it due to size limitations.

We appreciate any feedback about the proper way to correct
FLAIR images for bias fields and normalize white matter
intensity in FLAIR images.

Thank you
JamesB


___
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 
 .
Please note that this e-mail is not secure (encrypted).  If you do not wish to 
continue communication over unencrypted e-mail, p

Re: [Freesurfer] SAMSEG - modification of the template files

2022-09-25 Thread Douglas N. Greve



On 9/25/2022 5:06 AM, Mikolaj Pawlak wrote:


External Email - Use Caution



On Fri, Sep 23, 2022 at 4:05 PM Douglas N. Greve 
 wrote:




On 9/22/2022 8:59 AM, Mikolaj Pawlak wrote:


External Email - Use Caution

Would providing better manual segmentations of those structures
of interest help you in building better solutions?
I can work with the segmentation that is produced now, but I am
interested in improving the results for extracerebral tissues
using multimodal imaging and better manual segmentations.


For extra cerebral, you can use the CHARM SAMSEG atlas 
(https://github.com/simnibs/charm-gems). SAMSEG is already modality 
agnostic and multimodal, so I'm not sure what you mean there.


The samseg authors used 20 subjects and did not find that
increasing that helped all that much (at least on dice scores)

That is promising - if the list of those subjects is public and they 
are part of the oasis dataset as indicated by the paper there is a way 
to subdivide the  segmentation of already existing labels

It may be possible, but won't happen soon.



Can you shed some light on the steps required for creating the
current atlas?

Unfortunately not. The atlas creation software was the lowest
priority of the samseg authors, so it is not easy to run. I
myself  find it extremely challenging to create new atlases, so I
can't support helping others do that. We're trying to get it more
streamlined (for you and for us:)


I see. If the process can be automated like in multi-atlas 
label fusion it would be a great way to gain more information about 
both cerebral and extracerebral tissues. Is building an atlas for 
T2-weighted images somewhere on the priority list?
again, samseg is already multimodal and modality independent (M3I), so 
this should not be necessary




thanks,
Mikolaj



thanks,

Mikolaj

On Wed, Sep 21, 2022 at 4:01 PM Douglas N. Greve
 wrote:

by template I'm assuming you mean the atlas. There is not an
easy way to create a new atlas or modify the existing one
(though we are developing methods to do both). For the eyes,
you could probably just write something to look at the column
index in the eyes. If it is less than 128, then set it to
left otherwise right.

On 9/21/2022 6:01 AM, Mikolaj Pawlak wrote:


External Email - Use Caution

Dear Freesurfers,
I have been using samseg for a while and like it a lot.
Thank you for this tool. How do you modify the template for
this tool? Is there a guideline for this?
I would like to divide Fluid_Inside_Eyes label to left and
right and improve the bone information in the template. What
is the procedure?
thanks,
Mikolaj Pawlak

___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
*MailScanner has detected a possible fraud attempt from
"secure-web.cisco.com" claiming to be*
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer  



___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
*MailScanner has detected a possible fraud attempt from
"secure-web.cisco.com" claiming to be*
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 *MailScanner has detected a possible
fraud attempt from "secure-web.cisco.com" claiming to be*
https://www.massgeneralbrigham.org/complianceline



Re: [Freesurfer] Sclimbic segmentation error

2022-09-25 Thread Douglas N. Greve
This is a bug. I've attached a new version. You can copy it to 
$FREESURFER/python/scripts/mri_sclimbic_seg

doug


On 9/23/2022 5:29 PM, bar gen wrote:


External Email - Use Caution

Hi all,
I am receiving this error when trying to run sclimbic module.

mri_sclimbic_seg --i /Users/mdbargen/Documents/control-T1--o 
/Users/mdbargen/Documents/control-limbic--conform


Segmenting image 1/68


Loaded input image from 
/Users/barisgenc/Documents/Kontrol-T1/Acar_Ebru-T1.nii.gz



Traceback (most recent call last):


File "/Applications/freesurfer/7.3.2/python/scripts/mri_sclimbic_seg", 
line 1048, in 



main()


File "/Applications/freesurfer/7.3.2/python/scripts/mri_sclimbic_seg", 
line 312, in main



segmenter.process_files(**params)


File "/Applications/freesurfer/7.3.2/python/scripts/mri_sclimbic_seg", 
line 577, in process_files



post, seg, vox_counts, volumes, mean_probs = self.segment(image)


File "/Applications/freesurfer/7.3.2/python/scripts/mri_sclimbic_seg", 
line 497, in segment



conformed = self.preprocess(image)


File "/Applications/freesurfer/7.3.2/python/scripts/mri_sclimbic_seg", 
line 469, in preprocess



print('The input image has resolution (%4.2f,%4.2f,%4.2f) mm, but 
1mm-isotropic input is required.\n'



TypeError: only size-1 arrays can be converted to Python scalars

How can i solve this?


___
Freesurfer mailing list
Freesurfer@nmr.mgh.harvard.edu
https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
#!/usr/bin/env python

import os
import time
import sys
import csv
import glob
import tempfile
import shutil
import platform
import argparse
import numpy as np
import surfa as sf
import scipy.ndimage


# defer tensorflow import until we need it (for faster command-line parsing)
tf = None


description = """
Segment subcortical limbic structures.

Input images can be provided by one of two methods. To segment one
or multiple T1-weighted images, use the --i flag to point to an
input image file or directory containing a series of images. The
--o flag should specify the corresponding output segmentation file
or directory. For example:

mri_sclimbic_seg --i image.mgz --o seg.mgz

To process a series of freesurfer recon-all subjects, use the --s
input flag. When no arguments are provided to this flag, subjects
will be searched for in the 'subjects directory' defined by the
--sd flag or the SUBJECTS_DIR env variable. Otherwise, a set of
subject names can be specified as arguments. For example:

mri_sclimbic_seg --s subj1 subj2 subj3

In freesurfer subject-mode, outputs will be saved to the subject's
mri and stats subdirectories, and volumetric stats will be computed
and saved automatically.
"""


# 

# Main Entrypoint
# 



def main():

# configure command-line
parser = argparse.ArgumentParser(description=description)

# normal-mode options
parser.add_argument('-i', '--i', help='T1-w image(s) to segment. Can be a 
path to a single image or a directory of images.')
parser.add_argument('-o', '--o', help='Segmentation output (required if --i 
is provided). Must be the same type as '
'the input path (a single file or 
directory).')

# subject-mode options
parser.add_argument('-s', '--s', nargs='*', help='Process a series of 
freesurfer recon-all subjects (enables subject-mode).')
parser.add_argument('--sd', help='Set the subjects directory (overrides the 
SUBJECTS_DIR env variable).')

# general options
parser.add_argument('--conform', action='store_true', help='Resample input 
to 1mm-iso; results will be put back in native resolution.')
parser.add_argument('--etiv', action='store_true', help='deInclude eTIV in 
volume stats (enabled by default in subject-mode and --tal).')
parser.add_argument('--tal', help='Alternative talairach xfm transform for 
estimating TIV. Can be file or suffix (for multiple inputs).')
parser.add_argument('--write_posteriors', action='store_true', help='Save 
the label posteriors.')
parser.add_argument('--write_volumes', action='store_true', help='Save 
label volume stats (enabled by default in subject-mode).')
parser.add_argument('--write_qa_stats', action='store_true', help='Save QA 
stats (z and confidence).')
parser.add_argument('--exclude', type=int, nargs='+', default=[], 
help='List of label IDs to exclude in any output stats files.')
parser.add_argument('--keep_ac', action='store_true', help='Explicitly keep 
anterior commissure in the volume/qa files.')
parser.add_argument('--vox-count-volumes', action='store_true', help='Use 
discrete voxel count for label volumes.')
parser.add_argument('--model', help='Alternative model weights to load.')
parser.ad

Re: [Freesurfer] SAMSEG - modification of the template files

2022-09-25 Thread Mikolaj Pawlak
External Email - Use Caution

On Fri, Sep 23, 2022 at 4:05 PM Douglas N. Greve 
wrote:

>
>
> On 9/22/2022 8:59 AM, Mikolaj Pawlak wrote:
>
> External Email - Use Caution
> Would providing better manual segmentations of those structures of
> interest help you in building better solutions?
> I can work with the segmentation that is produced now, but I am interested
> in improving the results for extracerebral tissues using multimodal imaging
> and better manual segmentations.
>
> The samseg authors used 20 subjects and did not find that increasing that
> helped all that much (at least on dice scores)
>
That is promising - if the list of those subjects is public and they are
part of the oasis dataset as indicated by the paper there is a way to
subdivide the  segmentation of already existing labels

> Can you shed some light on the steps required for creating the current
> atlas?
>
> Unfortunately not. The atlas creation software was the lowest priority of
> the samseg authors, so it is not easy to run. I myself  find it extremely
> challenging to create new atlases, so I can't support helping others do
> that. We're trying to get it more streamlined (for you and for us:)
>

I see. If the process can be automated like in multi-atlas label fusion it
would be a great way to gain more information about both cerebral and
extracerebral tissues. Is building an atlas for T2-weighted images
somewhere on the priority list?

thanks,
Mikolaj


>
>
> thanks,
>
> Mikolaj
>
> On Wed, Sep 21, 2022 at 4:01 PM Douglas N. Greve 
> wrote:
>
>> by template I'm assuming you mean the atlas. There is not an easy way to
>> create a new atlas or modify the existing one (though we are developing
>> methods to do both). For the eyes, you could probably just write something
>> to look at the column index in the eyes. If it is less than 128, then set
>> it to left otherwise right.
>>
>> On 9/21/2022 6:01 AM, Mikolaj Pawlak wrote:
>>
>> External Email - Use Caution
>> Dear Freesurfers,
>> I have been using samseg for a while and like it a lot. Thank you for
>> this tool. How do you modify the template for this tool? Is there a
>> guideline for this?
>> I would like to divide Fluid_Inside_Eyes label to left and right and
>> improve the bone information in the template. What is the procedure?
>> thanks,
>> Mikolaj Pawlak
>>
>> ___
>> Freesurfer mailing listfreesur...@nmr.mgh.harvard.edu*MailScanner has 
>> detected a possible fraud attempt from "secure-web.cisco.com" claiming to 
>> be* 
>> https://secure-web.cisco.com/1GWqfB7tG8HCWZgCRPEm38jICApGGWm5W-V-EFWXyg-Z1BO2HS6hxlAH54e4RKZTyNZi4WjBT4IVWiNXMD2ewgIWWN8PpR-q7XlBJzOFFZx3_i4Wua9bqHZfLSnyuGYQBzCAyAZI026nAiRa55L2gLZvYtMPzkVr9Mo7pTRs1IjB8Zw1atcbjBQVLdNvuRyN4hUw8aPIl_gKP-6ibwZc8S49_Y0RuLrtuIOqdFah-64-E_wkVHjbutKrvLtHz2bu1c1vP9QoOmVyDz-d8H1RRZp0DwE9T68zs74kQJPFbxINExf235wse4OfmZcWDMsFF/https%3A%2F%2Fmail.nmr.mgh.harvard.edu%2Fmailman%2Flistinfo%2Ffreesurfer
>>  
>> 
>>
>>
>> ___
>> Freesurfer mailing list
>> Freesurfer@nmr.mgh.harvard.edu
>> *MailScanner has detected a possible fraud attempt from
>> "secure-web.cisco.com" claiming to be*
>> https://secure-web.cisco.com/1GWqfB7tG8HCWZgCRPEm38jICApGGWm5W-V-EFWXyg-Z1BO2HS6hxlAH54e4RKZTyNZi4WjBT4IVWiNXMD2ewgIWWN8PpR-q7XlBJzOFFZx3_i4Wua9bqHZfLSnyuGYQBzCAyAZI026nAiRa55L2gLZvYtMPzkVr9Mo7pTRs1IjB8Zw1atcbjBQVLdNvuRyN4hUw8aPIl_gKP-6ibwZc8S49_Y0RuLrtuIOqdFah-64-E_wkVHjbutKrvLtHz2bu1c1vP9QoOmVyDz-d8H1RRZp0DwE9T68zs74kQJPFbxINExf235wse4OfmZcWDMsFF/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 *MailScanner has detected a possible
>> fraud attempt from "secure-web.cisco.com" claiming to be*
>> https://secure-web.cisco.com/1Tbae9C4ZSANyVYaR6Pwd4nbrTvfaCoHgElc8UmkFRzMGRJwrtZkEBayD_RW2CfJx_WJqpsMKUMFtEGZfNB0W24oX0iJxWcoqF