Hi 

Previous scripts are good but if you feel confused because you do not have that experience with scripting you can try another way;

For creating directories;

for i in 01 02 03 04 05 .....; do mkdir -p C${i}/mri/orig ; done

replace dots (.....) with numbers as much as you want and replace C with your subjects' ID


For runing mri_convert command;

for i in 01 02 03 04 05; do mri_convert C${i}.nii.gz  C${i}/mri/orig/001.mgz ; done

again replace dots (.....) with numbers as much as you want and replace C with your subjects' ID


or even you can try the following applescript if you have mac system

display dialog "Choose your shell type" buttons {"bash", "csh or tcsh", "Cancel"} ¬

with title ""

set diag1button to button returned of result


if diag1button is "bash" then

tell application "Terminal"

set currentTab to do script "export FREESURFER_HOME=/Applications/freesurfer

source $FREESURFER_HOME/SetUpFreeSurfer.sh"

end tell

else if diag1button is "csh or tcsh" then

tell application "Terminal"

set currentTab to do script "setenv FREESURFER_HOME /Applications/freesurfer

source $FREESURFER_HOME/SetUpFreeSurfer.csh"

end tell

end if


set destination to (choose folder with prompt "Choose the destination folder")


set this_folder1 to choose folder with prompt "Data directory"

set dir to "mri/orig"

tell application "Finder"

set thePath1 to POSIX path of this_folder1

set mylist to get name of folders of this_folder1

set stringsList to mylist

set theChoices to ¬

choose from list stringsList with prompt "You can select more than one subject's ID from the list below; 

Please use mous click and Command key to highlight your selection" with title "" with multiple selections allowed

set x to result as string

repeat with x in theChoices

set subjectid to x as string

set ThePath3 to POSIX path of this_folder1 & subjectid

set t to (do shell script "ls " & quoted form of ThePath3)

set beginningToEnd to text of first paragraph of t

set folderName to x as string

tell application "Finder"

make folders in destination with properties {name:folderName}

set this_folder to folderName

set ThePath to POSIX path of destination

set thePath2 to POSIX path of destination & this_folder

tell application "Terminal"

set currentTab to do script "cd" & space & quoted form of thePath2 in window 1

set currentTab to do script "mkdir -p" & space & quoted form of dir in window 1

set currentTab to do script "mri_convert" & space & quoted form of ThePath3 & "/" & quoted form of beginningToEnd & space & quoted form of thePath2 & "/mri/orig/" & "001.mgz" in window 1

end tell

end tell

end repeat

end tell





On 16 July 2011 18:28, <freesurfer-request@nmr.mgh.harvard.edu> wrote:
Send Freesurfer mailing list submissions to
       freesurfer@nmr.mgh.harvard.edu

To subscribe or unsubscribe via the World Wide Web, visit
       https://mail.nmr.mgh.harvard.edu/mailman/listinfo/freesurfer
or, via email, send a message with subject or body 'help' to
       freesurfer-request@nmr.mgh.harvard.edu

You can reach the person managing the list at
       freesurfer-owner@nmr.mgh.harvard.edu

When replying, please edit your Subject line so it is more specific
than "Re: Contents of Freesurfer digest..."


Today's Topics:

  1. Re: how can do ''mri_convert''quickly when there are      too many
     subjects (Peter J. Molfese)
  2. Re :  Book with FreeSurfer chapter (Simmons, Andy)


----------------------------------------------------------------------

Message: 1
Date: Sat, 16 Jul 2011 12:40:27 -0400
From: "Peter J. Molfese" <Peter.Molfese@yale.edu>
Subject: Re: [Freesurfer] how can do ''mri_convert''quickly when there
       are     too many subjects
To: freesurfer@nmr.mgh.harvard.edu
Message-ID: <703DA8F6-7DD5-41A2-BD5C-0180EA4802D6@yale.edu>
Content-Type: text/plain; charset="us-ascii"

A script is definitely the easiest way to process quite a few subjects.  You can save some headache by using a recon-all command with an input for your image files.  For example: "recon-all -s sleep_001 -i sleep_001.nii -all" will create a subject folder in the correct location named sleep_001 and begin the entire freesurfer pipeline taking the NIFTI image sleep_001.nii as the input.  You can modify it to just import the files by dropping the "-all".

I've included a bash script below for simplifying this.  This script takes the NIFTI files you want to process as arguments and then automatically sets the Subject ID and begins processing.  Once it completes a single subject, it will start the next subject.  You can track the progress of subjects by seeing which folders have been created in the SUBJECTS_DIR.  If you have a multiprocessor system, you can run the script with different subjects in multiple terminal windows.

To execute the script:
1. Save the script as fs_subject.sh
2. chmod +x fs_subject.sh
3. place the script in a folder with all of your NIFTI files (not required but may make your life easier)
4. execute the script with ./fs_subject.sh sleep_001.nii sleep_002.nii sleep_003.nii (don't forget to replace sleep_* with your NIFTI file names)
4a. If your subjects meet a standard naming convention you could do something like: ./fs_subject.sh sleep_*.nii (this would submit all subjects fitting the pattern of having "sleep_" at the beginning of the name.


#!/bin/bash
# ./fs_subject.sh
# takes nifti files as arguments for submitting into freesurfer pipeline

#setup Freesurfer if not currently loaded on path
export FREESURFER_HOME=/usr/local/freesurfer
#source $FREESURFER_HOME/SetUpFreeSurfer.sh
. $FREESURFER_HOME/SetUpFreeSurfer.sh

for FS in $*
do
  subjectID=$(/bin/echo $FS | /usr/bin/sed 's/.nii//')
  recon-all -s $subjectID -i $FS -all
done

Hope this helps!  Ultimately if you have a lot of computers and a lot of subjects, using Sun Grid Engine (SGE) or Apple's xgrid (if you have Macs) can really expedite the processing of subjects.

Best,
Peter


> Date: Fri, 15 Jul 2011 12:22:38 -0500
> From: Freesurfer Local Archive <freesurfer@jonca.org>
> Subject: Re: [Freesurfer] how can do ''mri_convert''quickly when there
>       are too many subjects
> To: ??? <wgh0805@126.com>
> Cc: freesurfer <freesurfer@nmr.mgh.harvard.edu>
> Message-ID:
>       <CABphhh-ZcMapCqq+0x66d0EXqQgdt-vPVojXt30O0P63kzoLAw@mail.gmail.com>
> Content-Type: text/plain; charset=UTF-8
>
> I suspect that your subject directory/file names will match some
> pattern. You can use combination of a loop and shell "ls" command to
> cycle through all the subjects matching provided pattern. For example
> if you have data in directories you would do something line this:
>
> #!/bin/tcsh
>
> cd /path/to/native/files
>
> for x in `ls -dA1 name_pattern_*`;
> do
> mkdir -p $SUBJECTS_DIR/${x}/mri/orig
> $FREESURFER_HOME/bin/mri_convert ${x}.nii.gz $SUBJECTS_DIR/${x}/mri/orig/001.mgz
> done
>
> If all files are in the same directory substitute '-dA1' for "-A1" and
> it should work. Note this assumes that you have nifti files, for DICOM
> you will need to modify it further.
>
> Cheers,
>
> Jacek
>
> 2011/7/15 ??? <wgh0805@126.com>:
>> ??Hi Bruce,
>>
>> ?????In our research,if there are?100 subjects,how?can I ?process these data
>> easily.For example?when I want to compare their thickness's difference?at
>> first?I should do
>> " mri_convert? bert.nii bert.nii.gz",but when there are too many subjects,is
>> there a way to do all of these 100 subjects at the same time?
>>
>> ?Many thanks,
>> ?Wang
>>
>>
>>
>> _______________________________________________
>> 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 Partners Compliance
>> HelpLine at
>> http://www.partners.org/complianceline . If the e-mail was sent to you in
>> error
>> but does not contain patient information, please contact the sender and
>> properly
>> dispose of the e-mail.
>>
>>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/freesurfer/attachments/20110716/f4efb417/attachment-0001.html

------------------------------

Message: 2
Date: Sat, 16 Jul 2011 18:26:50 +0100
From: "Simmons, Andy" <andy.simmons@kcl.ac.uk>
Subject: [Freesurfer] Re :  Book with FreeSurfer chapter
To: "freesurfer@nmr.mgh.harvard.edu" <freesurfer@nmr.mgh.harvard.edu>
Message-ID:
       <EADA37A458FAEF4F8921F4A97317C8B19C2AFDB876@KCL-MAIL03.kclad.ds.kcl.ac.uk>

Content-Type: text/plain; charset="iso-8859-1"

There are also several other chapters of the same book using Freesurfer in AD, including


Magnetic Resonance Imaging and Magnetic Resonance Spectroscopy for Detection of Early Alzheimer's
Disease / Eric Westman, Lars-Olof Wahlund, Catherine Foy, Michaela Poppe, Allison Cooper, Declan Murphy,

Christian Spenger, Simon Lovestone and Andrew Simmons


Combinatorial Markers of Mild Cognitive Impairment Conversion to Alzheimer's Disease - Cytokines and MRI
Measures Together Predict Disease Progression / Simon J. Furney, Deborah Kronenberg, Andrew Simmons,
Andreas G?ntert, Richard J. Dobson, Petroula Proitsi, Lars-Olof Wahlund, Iwona Kloszewska, Patrizia Mecocci,

Hilkka Soininen, Magda Tsolaki, Bruno Vellas, Christian Spenger and Simon Lovestone



Best wishes,



Andy Simmons



-----



Date: Fri, 15 Jul 2011 20:36:01 -0300

From: Pedro Paulo de Magalh?es Oliveira Junior <ppj@netfilter.com.br>

Subject: [Freesurfer] Book with FreeSurfer chapter

To: Freesurfer Mailing List <freesurfer@nmr.mgh.harvard.edu>

Message-ID:

     <CAPSXCjqtiYDJMAFvxGWu=k9NuTE8zf1JdOAwMv3HSBiuAwQhSQ@mail.gmail.com>

Content-Type: text/plain; charset="iso-8859-1"



Just for information:



*Handbook of Imaging the Alzheimer Brain*

*

Editors: J.W. Ashford, A. Rosen, M. Adamson, P. Bayley,

O. Sabri, A. Furst, S.E. Black and M. Weiner

July 2011, 824 pp., hardcover

ISBN 978-1-60750-792-5 (print)

**



The chapter that describes the usage of FreeSurfer in AD is "Automated

Volumetric Methods to Detect Alzheimer's Disease" / Pedro Paulo de Magalh?es

Oliveira Jr. et al.

*


----

Dr Andy Simmons
Reader in Neuroimaging & Consultant Clinical Scientist
Centre for Neuroimaging Sciences and NIHR Biomedical Research Centre
Institute of Psychiatry, Box P089
Kings College London
De Crespigny Park
London, SE5 8AF, UK

Email - andy.simmons@kcl.ac.uk
Webpage  - http://www.iop.kcl.ac.uk/staff/profile/default.aspx?go=10338
Directions - http://www.iop.kcl.ac.uk/virtual/?path=/about/how-to-find-the-institute-of-psychiatry/
ResearcherID - http://www.researcherid.com/rid/B-8848-2008
Fax +44 (0)203 228 2116

[cid:image001.png@01CC43EE.317991F0]<http://msc-neuroimaging.com/>

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.nmr.mgh.harvard.edu/pipermail/freesurfer/attachments/20110716/08a90325/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 40810 bytes
Desc: image001.png
Url : http://mail.nmr.mgh.harvard.edu/pipermail/freesurfer/attachments/20110716/08a90325/attachment.png

------------------------------

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

End of Freesurfer Digest, Vol 89, Issue 52
******************************************



--
Jamaan Alghamdi
07779801950
0151 795 4627
Magnetic Resonance & Image Analysis Research Centre (MARIARC)
University of Liverpool
Pembroke place
Liverpool
L69 3GE

http://web.mac.com/jamaan/Jamaan/Welcome.html    
http://www.easyneuroimaging.com/