I'm trying to manipulate a series of DICOM files for a registration project, but I have not been able to save the files with the header they came with. This eliminates the pixel spacing information, which is necessary to perform the registration.
I have installed the Tudor tools in order to manipulate files, but I have not been able to utilize the header from either end of the process. I can access the header from the Tudor DICOM manager, but if I open the file series the resulting picture in ImageJ does not have a header or any of the associated spacing information. I have also tried opening the file series with the Bio-Formats Importer. This successfully retains the header and applies the spacing information while I am manipulating it in ImageJ, but if I save the files to a DICOM they no longer have the header information as part of them. I have seen several mentions that the Tudor system is supposed to retain and easily manipulate header data, but I have not been able to figure out how it does so. I do not have access to a hospital PACS system, if that is part of the solution. Does anyone know a plugin or a correct methodology so that I can manipulate the files without losing the header information? -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Michael,
I had a similar problem and solved by a work-around: Split the header and raw image data in separate files, edit and save the raw image and glue the files together again. File split files via a macro, see below. This will generate two files (.header and .image) and a log window with information to load the raw image data (width, height and #bits). For 16 bits images you have to find out if it uses little or big endian byte order (see file>import>raw dialog) and when saving via save_as > raw data you can set this in the options>io>"Save raw in intel byte order". To glue the files to a new dicom file I use the dos command: "copy /b file.header + file.image file.dcm" It's a bit tricky but works for me. Bruno. Macro: path=File.openDialog("Open DICOM file") open(path); // open DICOM file file_size=File.length(path); header_size=getNumericTag("7FE0,0010"); // offset to image data print("file: "+path); print("rows "+ getNumericTag("0028,0010")); print("columns "+ getNumericTag("0028,0011")); print("bits "+ getNumericTag("0028,0100")); print("samples per pixel "+ getNumericTag("0028,0002")); close(); run("Raw...", "open=" + path + " image=8-bit width=1 height="+header_size+" offset=0 number=1 gap=0 little-endian"); saveAs("Raw Data", path+".header"); close(); run("Raw...", "open=" + path + " image=8-bit width=1 height=" + file_size-header_size + " offset=header_size number=1 gap=0 little-endian"); saveAs("Raw Data", path+".image"); close(); // This function returns the numeric value of the // specified tag (e.g., "0018,0050"). Returns NaN // (not-a-number) if the tag is not found or it // does not have a numeric value. function getNumericTag(tag) { value = getTag(tag); if (value=="") return NaN; index3 = indexOf(value, "\\"); if (index3>0) value = substring(value, 0, index3); value = 0 + value; // convert to number return value; } // This function returns the value of the specified // tag (e.g., "0010,0010") as a string. Returns "" // if the tag is not found. function getTag(tag) { info = getImageInfo(); index1 = indexOf(info, tag); if (index1==-1) return ""; index1 = indexOf(info, ":", index1); if (index1==-1) return ""; index2 = indexOf(info, "\n", index1); value = substring(info, index1+1, index2); return value; } -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |