Login  Register

Macro to open DICOM stack, rename stack, save stack

Posted by yxnsn on Jun 16, 2015; 8:25pm
URL: http://imagej.273.s1.nabble.com/Macro-to-open-DICOM-stack-rename-stack-save-stack-tp5013190.html

Hi all, I'm a beginner at programming and would like some help with my macro code. 

I'm trying to 1) Import a selection of various folders containing DICOM images as individual image sequences; 2) Rename the respective individual folders using info extracted from images' DICOM header; 3) Save the DICOM images as a .tiff image sequence in their respective renamed folders.

The code should cycle through one folder at a time. 

Dir = getDirectory("Choose a directory "); 
list = getFileList(Dir); 
setBatchMode(true); 
for (i=0; i<list.length;i++) { 
run("Image Sequence...", "open=["+Dir+list[i]+"] sort"); 
seriesName = getInfo("0008,103E"); //This is a plugin that extracts info from DICOM header 
File.makeDirectory(Dir+File.separator+seriesName); 
run("Image Sequence...", "format=TIFF save=[Dir+list[i],Dir+File.separator+seriesName]") 


I believe my problem is in the "save" part, I'm not sure what the right code should be. Also, I’d love to learn if I could’ve implemented this code in a more simple way. 
 

Thanks for the help!