Trouble with setMinAndMax() and exporting an AVI in IJM macro

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
rcz
Reply | Threaded
Open this post in threaded view
|

Trouble with setMinAndMax() and exporting an AVI in IJM macro

rcz
Hello,

I am trying to write what I hope is a simple script: I would like to import
a sequence of DICOM files, adjust the window width and level, and export the
series as an AVI. However, I am having some difficulty and I'm hoping
someone can provide me some assistance -- I would appreciate it!

Using the IJM macro recorder in FIJI, I devised something like this:

/run("Image Sequence...", "open=[path/to/dicom/folder/0001.dcm] file=[.dcm]
use sort");
setMinAndMax(152, 879); // Note that I calculated the inputs manually as
opposed to using the values from the macro
run("AVI... ", "compression=JPEG frame=7
save=[path/to/output/folder/out.avi]");
saveAs("Jpeg", "path/to/output/folder/out.jpg");/

Upon running the recorded macro, the output AVI has an incorrect window
width and level from that specified by my call to /setMinAndMax/(); from
what I can tell via debugging, it appears to have just exported the DICOM
image sequence as imported. However, I am getting the correct visual output
from the output jpg file, which I exported to serve as a test. So, I'm
rather stumped.

I am using FIJI with ImageJ 1.52p, Java 1.8.0_172 (64-bit), and a Windows 10
PC.

Thanks for reading and have a great day!



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with setMinAndMax() and exporting an AVI in IJM macro

Straub, Volko A. (Dr.)
Hm, I tried to reproduce the problem, but when I save a sequence as avi files, the avi file reflects the min and max settings (at least when I open the avi file in Fiji-ImageJ  v1.52p on a Windows PC)
I suspect your issue is due to the fact that setMinAndMax() alters the display range without actually altering the pixel values. When you re-open the avi file, it somehow appears to have 'forgotten' the display range and changed back to the original (auto) range. As the pixel values haven't changed from the original images, the images in the movie look the same.
You can probably get around this by including run("Apply LUT") after the setMinAndMax() command, which will alter the pixel values of the image and should be reflected in the exported output file.
Hope this helps,
Volko

________________________________

Subject: Trouble with setMinAndMax() and exporting an AVI in IJM macro

Hello,

I am trying to write what I hope is a simple script: I would like to import
a sequence of DICOM files, adjust the window width and level, and export the
series as an AVI. However, I am having some difficulty and I'm hoping
someone can provide me some assistance -- I would appreciate it!

Using the IJM macro recorder in FIJI, I devised something like this:

/run("Image Sequence...", "open=[path/to/dicom/folder/0001.dcm] file=[.dcm]
use sort");
setMinAndMax(152, 879); // Note that I calculated the inputs manually as
opposed to using the values from the macro
run("AVI... ", "compression=JPEG frame=7
save=[path/to/output/folder/out.avi]");
saveAs("Jpeg", "path/to/output/folder/out.jpg");/

Upon running the recorded macro, the output AVI has an incorrect window
width and level from that specified by my call to /setMinAndMax/(); from
what I can tell via debugging, it appears to have just exported the DICOM
image sequence as imported. However, I am getting the correct visual output
from the output jpg file, which I exported to serve as a test. So, I'm
rather stumped.

I am using FIJI with ImageJ 1.52p, Java 1.8.0_172 (64-bit), and a Windows 10
PC.

Thanks for reading and have a great day!



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&data=02%7C01%7Cvs64%40leicester.ac.uk%7C3d143d931af741ec894208d844bf13b8%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637334934746973068&sdata=lv94egIHok9ToUSnvfpjouiMgSiNAiLOBtsUIHO%2BhXM%3D&reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&data=02%7C01%7Cvs64%40leicester.ac.uk%7C3d143d931af741ec894208d844bf13b8%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637334934746973068&sdata=TpbAsSSL3apYu9T2dc8uNz03yhf3gTynHBPm5vMpq60%3D&reserved=0

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html
rcz
Reply | Threaded
Open this post in threaded view
|

Re: Trouble with setMinAndMax() and exporting an AVI in IJM macro

rcz
Hello Volko,

Thank you for your reply and your insights therein. I attempted to add your
suggestion to my macro, and FIJI gave me a "Macro Error" asking me to either
process it as a virtual stack (Process>Batch>Virtual Stack) or to convert it
to a normal stack (Image>Duplicate). So, I added the command
'run("Duplicate...", "duplicate")' to the macro before the call to
'run("Apply LUT")' and it worked as I was expecting. Furthermore, through
further testing, it seemed as though the call to apply LUT was unnecessary;
simply first duplicating the stack produced the desired output AVI.

So, again, thanks for helping me reach a solution to my problem! And, I hope
this helps anyone else who might be experiencing something similar.



--
Sent from: http://imagej.1557.x6.nabble.com/

--
ImageJ mailing list: http://imagej.nih.gov/ij/list.html