How to load image files without extensions

1,089 views
Skip to first unread message

kobachan

unread,
May 30, 2011, 2:17:44 AM5/30/11
to itksnap-users
On May 29, snapangelo writes just what I wanted to say. Thanks!
Now the link that I mentioned on May 25
(http://www.itksnap.org/pmwiki/pmwiki.php?
n=Documentation.TutorialRawInput)
becomes active again and says "The user must specify information about
how data in the file is organized."
My file without format information is actually a DICOM file and can be
opened with DICOM viewers.
I would like to know how you read it using ITK-SNAP.
Thank you again in advance.

ara.ye...@uniklinik-freiburg.de

unread,
May 30, 2011, 8:41:40 AM5/30/11
to itksna...@googlegroups.com
Hi,
I'm also interested in knowing this. I had the same problem some time ago, so I just wrote a small Python script to automatically assign extensions to files without ones.
Thanks in advance.
Ara Yeramian
--
You received this message because you are subscribed to the Google Groups "itksnap-users" group.
To post to this group, send email to itksna...@googlegroups.com.
To unsubscribe from this group, send email to itksnap-user...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/itksnap-users?hl=en.


Tom Schoenemann

unread,
May 31, 2011, 8:59:00 AM5/31/11
to itksna...@googlegroups.com
A simple shell script can also change the file extensions (or add file extensions).  You can easily add ".dcm" (or whatever extension you want) to all the files in a directory using the command line by doing:

for i in $( ls * ); do mv $i $i.dcm ;done

If you are paranoid, you could make copies of the files, leaving the original ones untouched, by doing:

for i in $( ls * ); do cp $i $i.dcm ;done

If you have the utility "sed" in your command line (comes with Mac OS X and Linux, but not sure about Windows), you can also easily change the extension from one thing (e.g., ".DICOM" to another (".dcm") for every file in a directory.

lets say you want to change all files like:
blah.DICOM 
to look like:
blah.dcm

do this:
for i in $(ls *.DICOM | sed 's/.DICOM//' ); do mv $i.DICOM $i.dcm ;done


[explanation of how the shell command works, for those interested: 

"for i in $( [something here] )" goes through (or does) whatever is in "[something here]", assigning each instance of "something here" to the variable "i", one at a time

"ls *.DICOM" lists all files in a directory ending in ".DICOM"

"|" (a "pipe") sends the output of whatever came before (in this case, a listing of all the files ending in ".DICOM") to a new command (in this case, the "sed" command)

" sed 's/.DICOM//' " removes the ".DICOM" from the name of each instance that the "ls" command found. Note that it does this in the scripts list, internally, only -- it doesn't change the actual name of the file on your disk.

" do mv $i.DICOM $i.dcm " takes each "i" (determined in the "for i in $...." step above), looks for a filename corresponding to $i.DICOM, and renames it with "mv" to $i.dcm.

This "for i in $..." is great for some set of repeated actions you want to do on a set of files in a directory.

Hope this is useful to someone!

-Tom

Paul Yushkevich

unread,
May 31, 2011, 12:30:05 PM5/31/11
to itksna...@googlegroups.com
Tom,

Thanks for the tip! Another avenue is to convert the DICOM directory
to NIFTI using the dcm2nii tool that is part of MRIcron. This can also
in the process anonymize the data.

http://www.cabiatl.com/mricro/mricron/index.html

Paul.

--
Paul A. Yushkevich, Ph.D.
Assistant Professor
Penn Image Computing and Science Laboratory
Department of Radiology
University of Pennsylvania

laurent paul

unread,
Jun 1, 2011, 3:00:31 AM6/1/11
to itksnap-users
Hi guys,

These command lines are interesting, but you can use a small software
that do the job for you: rnameit
However, I think it only works under windows...

Laurent.



On 31 mai, 14:59, Tom Schoenemann <tom.schoenem...@gmail.com> wrote:
> A simple shell script can also change the file extensions (or add file extensions).  You can easily add ".dcm" (or whatever extension you want) to all the files in a directory using the command line by doing:
>
> for i in $( ls * ); do mv $i $i.dcm ;done
>
> If you are paranoid, you could make copies of the files, leaving the original ones untouched, by doing:
>
> for i in $( ls * ); do cp $i $i.dcm ;done
>
> If you have the utility "sed" in your command line (comes with Mac OS X and Linux, but not sure about Windows), you can also easily change the extension from one thing (e.g., ".DICOM" to another (".dcm") for every file in a directory.
>
> lets say you want to change all files like:
> blah.DICOM
> to look like:
> blah.dcm
>
> do this:
> for i in $(ls *.DICOM | sed 's/.DICOM//' ); do mv $i.DICOM $i.dcm ;done
>
> [explanation of how the shell command works, for those interested:
>
> "for i in $( [something here] )" goes through (or does) whatever is in "[something here]", assigning each instance of "something here" to the variable "i", one at a time
>
> "ls *.DICOM" lists all files in a directory ending in ".DICOM"
>
> "|" (a "pipe") sends the output of whatever came before (in this case, a listing of all the files ending in ".DICOM") to a new command (in this case, the "sed" command)
>
> " sed 's/.DICOM//' " removes the ".DICOM" from the name of each instance that the "ls" command found.  Note that it does this in the scripts list, internally, only -- it doesn't change the actual name of the file on your disk.
>
> " do mv $i.DICOM $i.dcm " takes each "i" (determined in the "for i in $...." step above), looks for a filename corresponding to $i.DICOM, and renames it with "mv" to $i.dcm.
>
> This "for i in $..." is great for some set of repeated actions you want to do on a set of files in a directory.
>
> Hope this is useful to someone!
>
> -Tom
>
> On May 30, 2011, at 8:41 AM, ara.yeram...@uniklinik-freiburg.de wrote:> Hi,
> > I'm also interested in knowing this. I had the same problem some time ago, so I just wrote a small Python script to automatically assign extensions to files without ones.
> > Thanks in advance.
> > Ara Yeramian
>
> > From:        kobachan <kobac...@nms.ac.jp>
> > To:        itksnap-users <itksna...@googlegroups.com>
> > Date:        30.05.2011 14:39
> > Subject:        [itksnap-users:760] How to load image files without extensions
> > Sent by:        itksna...@googlegroups.com
>
> > On May 29, snapangelo writes just what I wanted to say. Thanks!
> > Now the link that I mentioned on May 25
> > (http://www.itksnap.org/pmwiki/pmwiki.php?
> > n=Documentation.TutorialRawInput)
> > becomes active again and says "The user must specify information about
> > how data in the file is organized."
> > My file without format information is actually a DICOM file and can be
> > opened with DICOM viewers.
> > I would like to know how you read it using ITK-SNAP.
> > Thank you again in advance.
>
> > --
> > You received this message because you are subscribed to the Google Groups "itksnap-users" group.
> > To post to this group, send email to itksna...@googlegroups.com.
> > To unsubscribe from this group, send email to itksnap-user...@googlegroups.com.
> > For more options, visit this group athttp://groups.google.com/group/itksnap-users?hl=en.

preeti aggarwal

unread,
Jun 27, 2011, 3:24:39 AM6/27/11
to itksna...@googlegroups.com
Hi
can you please tell whether we can use ITK-SNAP for 3d medical image segmentation? I want to segment CT scan data of chest. Please help in this regard.
 
Best Regards
Preeti Aggarwal
CSE Deptt.
Univ. Instt. Of Engg. & Technology
Panjab University
Sector 25
Chandigarh.



From: Paul Yushkevich <pau...@mail.med.upenn.edu>
To: itksna...@googlegroups.com
Sent: Tue, May 31, 2011 4:30:05 AM
Subject: Re: [itksnap-users:770] How to load image files without extensions
> itksnap-users+unsub...@googlegroups.com.

> For more options, visit this group at
> http://groups.google.com/group/itksnap-users?hl=en.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "itksnap-users" group.
> To post to this group, send email to itksna...@googlegroups.com.
> To unsubscribe from this group, send email to
> itksnap-users+unsub...@googlegroups.com.

> For more options, visit this group at
> http://groups.google.com/group/itksnap-users?hl=en.
>
> --
> You received this message because you are subscribed to the Google Groups
> "itksnap-users" group.
> To post to this group, send email to itksna...@googlegroups.com.
> To unsubscribe from this group, send email to
> itksnap-users+unsub...@googlegroups.com.

> For more options, visit this group at
> http://groups.google.com/group/itksnap-users?hl=en.
>



--
Paul A. Yushkevich, Ph.D.
Assistant Professor
Penn Image Computing and Science Laboratory
Department of Radiology
University of Pennsylvania

--
You received this message because you are subscribed to the Google Groups "itksnap-users" group.
To post to this group, send email to itksna...@googlegroups.com.
To unsubscribe from this group, send email to itksnap-users+unsub...@googlegroups.com.

Marina Carbone

unread,
Jul 7, 2011, 5:32:58 PM7/7/11
to itksna...@googlegroups.com
Preeti, you can also point in the directory where you have the file (even if it looks empty)  and write "*.dcm"  and than OK. THe Sw will recognize any dicom /.DICOM /.dcm  images in your folder.
Regards
MC
To unsubscribe from this group, send email to itksnap-user...@googlegroups.com.

For more options, visit this group at http://groups.google.com/group/itksnap-users?hl=en.

--

Marina Carbone, Eng, PhD Student
EndoCAS Center
Università di Pisa
Ospedale di Cisanello, Via Paradisa 2
56124 Pisa, Italy
web: www.endocas.org
Phone: (+39) 050 995 689 - 25
Fax: (+39) 050 995 676
email: marina....@endocas.org
           m.ca...@sssup.it
Reply all
Reply to author
Forward
0 new messages