DICOM info AND measurements for multiple ROIs for a CT stack

Tags: #<Tag:0x00007fa301c48c08> #<Tag:0x00007fa301c48aa0> #<Tag:0x00007fa301c48938>


Another newbie to image J I’m afraid…
I am writing a code to go through various CT image stacks and extract mA and image number from the DICOM header file for each image slice, as well as pixel value and noise (standard deviation) in particular parts of the image:

I have the code working fine if I only use one ROI, however, if I add a second ROI (to allow me to investigate how changing parameters affects contrast between two regions), it gives the measurements for each ROI in separate rows (rows 1 to 4 have mean1, stDev1, imageNo and mA, but mean2 and stDev 2 are given in rows 5-8), which is no good as I need each image slice to occupy one row in the results table (with columns: mean1 stdev1, mean2, stdev2, image no, mA). However if I try to use Multi Measure, I have to open the stack rather than each image, which prevents me from retrieving the DICOM header info in the same results table.

The current iteration of my code is below. Any thoughts would be very welcome.

// choose file containing the DICOM files
dir1 = getDirectory("Choose source folder");

//identify location for results
dir2 = getDirectory("Choose for result file");

// set up loop - to go through all files in the stack
list = getFileList(dir1);
i = list.length
//showMessage("i = " + i);

 path = dir1+list[3];
run("Clear Results");    
//// position ROI on first slice and check with user    
run("Set Scale...", "distance=1 known=0 pixel=1 unit=pixel global");
run("Set Measurements...", "mean standard redirect=None decimal=0");
makeOval(249, 249, 16, 16);
title = "check ROI position";
msg = "Reposition the ROI so that it is located centrally\nwithin the central ring, then click \"OK\"";
waitForUser(title, msg);    
//showMessage("bounds: " +x);

makeOval(303, 296, 16, 16);
title = "check ROI position";
msg = "Reposition the ROI so that it is located centrally\nwithin the bottom right ring, then click \"OK\"";
waitForUser(title, msg);    
//showMessage("bounds: " +x);


//use batch mode to reduce on screen processing (doesn't display images)
//list = getFileList(dir1);
//i = list.length

run("Clear Results");
for (i=0; i<list.length; i++) {

    path = dir1+list[i];
//// make ROIs on each image slice and measure noise and pixel value

makeOval(x, y, w, h);

roiManager("Select", newArray(0,1)); 

//// retrieve slice no and tube current from DICOM header
imageNo = getInfo("0020,0013");
    mA = getInfo("0018,1151");

//// SET RESULTS ////    
setResult("imageNo", i, imageNo);
setResult("mA", i, mA);


//Set up name (series,date at time)
path = dir1+list[0];

date = getInfo("0008,0020");
//showMessage("date = " +date);

seriestime = getInfo("0008,0031");
series = getInfo("0008,103E");

d1 = substring(date,1,5)
d2 = substring(date,5,7);
d3 = substring(date,7,9);
t1 = substring(seriestime, 1,3);
t2 = substring(seriestime, 3,5);

name =series + " "+d3+"."+d2+"."+d1+" at "+t1+"."+t2 +".xls";
//showMessage("name = " +name);

saveAs("Results", dir2+name);
run("Close All");


Any ideas would be very welcome.



Image analysis and denoise

Hi @chloe

As far as I understand it the problem is to generate a well formatted output table. I usually use KNIME to rearrange my results. You can do this either after you extracted all your values with Fiji or you can use the KNIME Image Processing Extension to extract and handle your data.

If you can upload a small image stack I can help you to set up a basic workflow.



Thanks for your response. I have a small test stack (4 images) but the forum informs me that ‘new users cannot upload attachments’ … I can email them to you or upload them somewhere else if that helps…
In the meantime I’ll take a look at KNIME.



Unfortunately I couldn’t open the dicom files directly and I had to convert them with Fiji into tif and I had to extract the dicom meta-data into txt files with Fiji.

After this step I was able to open all files with KNIME and could build this workflow which extracts the right meta-data and ROI measurements and combines everything in a table.

This is the result table:

This is the workflow.zip (361.7 KB).

And here are the converted input files: test dicoms(4 images).zip (993.6 KB).