Please help creating a macro for Z project and save as .tif

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

Please help creating a macro for Z project and save as .tif

patriciody
Hi everyone,

I would like to know if someone could help me create a macro that will save
me a lot of time. I take photos of my fluorescent samples using 2 channels
and many z stacks, which gets saved as a .nd2 file. I would like to have a
macro that joins all Z stacks using Z project max intensity, then split the
2 channels into 2 individual pictures and save them as .tif

Would this be possible? I really appreciate if you could help me, and thanks
a lot in advance.



--
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: Please help creating a macro for Z project and save as .tif

Krs5
Dear Patriciody ,

If I understand you correct you have one nd2 file containing all the z-slices? If so, the macro below might do what you want (not tested).

dir1 = getDirectory("Select folder with nd2 files");
list = getFileList(dir1);
dir2 = getDirectory("Select folder to save the results");
for (i=0; i<list.length; i++){
// setBatchMode(true); // if all works fine you can remove the "// " at the start of this line to speed up the process; no images will be opened on the screen.
    path = dir1 + list[i];
run("Bio-Formats Importer", "open="+path"+ autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");
getDimensions(width, height, channels, slices, frames);
run("Make Substack...", "delete slices=1-"+slices+"-2");
run("Z Project...", "projection=[Max Intensity]");
saveAs("tif", dir2+"C1"+list[i]+".tif");
close();
selectWindow(list[i]);
run("Z Project...", "projection=[Max Intensity]");
saveAs("tif", dir2+"C2"+list[i]+".tif");
run("Close All");
}

Best wishes

Kees

________________________________


Hi everyone,

I would like to know if someone could help me create a macro that will save
me a lot of time. I take photos of my fluorescent samples using 2 channels
and many z stacks, which gets saved as a .nd2 file. I would like to have a
macro that joins all Z stacks using Z project max intensity, then split the
2 channels into 2 individual pictures and save them as .tif

Would this be possible? I really appreciate if you could help me, and thanks
a lot in advance.



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Caded84ec771c425f3d1108d800171cbd%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637259446557004995&amp;sdata=nAqdZEaXTPZ5ga6w8HZcoZPpfJ3v9d27E1qrxU7sDCo%3D&amp;reserved=0

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

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

Re: Please help creating a macro for Z project and save as .tif

patriciody
Dear Kees,

Sorry for my late reply. I have tried the macro but it gives a error saying:
Error: ')' expected in line 7:
                run ( "Bio-Formats Importer" , "open=" + path <"+ autoscale
color_mode=Default rois_import=[ROI manager] view=Hyperstac...


Thank you for your help



--
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: Please help creating a macro for Z project and save as .tif

Krs5
Sorry, there is a typo in the line

run("Bio-Formats Importer", "open="+path"+ autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

it should be:

run("Bio-Formats Importer", "open="+path+" autoscale color_mode=Default rois_import=[ROI manager] view=Hyperstack stack_order=XYCZT");

but not sure if this will solve the problem.

Kees

________________________________


Dear Kees,

Sorry for my late reply. I have tried the macro but it gives a error saying:
Error:          ')' expected in line 7:
                run ( "Bio-Formats Importer" , "open=" + path <"+ autoscale
color_mode=Default rois_import=[ROI manager] view=Hyperstac...


Thank you for your help



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7C9e046717bffa4f7f562708d803a7b32f%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C1%7C637263366095834417&amp;sdata=VZJ5h6Pg47BV7BPpJzveDFs7UmGg4C4CnVkGd6%2FKljE%3D&amp;reserved=0

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

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

Re: Please help creating a macro for Z project and save as .tif

patriciody
Hi Kees,

Sadly it says there is a similar error still.

Error: The specified file (/Volumes/Patricio/Spinning) does not exist. in
line 7:
                run ( "Bio-Formats Importer" , "open=" + path + " autoscale
color_mode=Default rois_import=[ROI manager] view=Hyperstac...


I am sorry to bother. Thank you



--
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: Please help creating a macro for Z project and save as .tif

Krs5
From: Straatman, Kees (Dr.) <[hidden email]>
Sent: 29 May 2020 13:43
To: [hidden email] <[hidden email]>
Subject: Re: Please help creating a macro for Z project and save as .tif

It seems it cannot find the file expected in the folder you have selected. Is it possible that besides the ND2 files there is a subfolder called Spinning in the selected folder?

Kees

________________________________

Hi Kees,

Sadly it says there is a similar error still.

Error:          The specified file (/Volumes/Patricio/Spinning) does not exist. in
line 7:
                run ( "Bio-Formats Importer" , "open=" + path + " autoscale
color_mode=Default rois_import=[ROI manager] view=Hyperstac...


I am sorry to bother. Thank you



--
Sent from: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.1557.x6.nabble.com%2F&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ca84a4cc70d4f4a63e7df08d803cd059c%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637263526382648915&amp;sdata=OonUiIYAZ3CGR0xomN39lt7kYg9%2FUWEgab0NSg25bs8%3D&amp;reserved=0

--
ImageJ mailing list: https://eur03.safelinks.protection.outlook.com/?url=http%3A%2F%2Fimagej.nih.gov%2Fij%2Flist.html&amp;data=02%7C01%7Ckrs5%40leicester.ac.uk%7Ca84a4cc70d4f4a63e7df08d803cd059c%7Caebecd6a31d44b0195ce8274afe853d9%7C0%7C0%7C637263526382648915&amp;sdata=VfIJe%2B0tAABbhyhJcDR%2Fs6%2Ffv3eyeBl%2F%2FxYu%2BdGIKlU%3D&amp;reserved=0

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

Re: Please help creating a macro for Z project and save as .tif

patriciody
Hi Kees! somebody answered via email this:

I tried to send this directly to the listserv... but.. it got rejected...
:-(
If your path has any spaces in it, you'll need to enclose it in brackets:
        run ( "Bio-Formats Importer" , "open=[" + path + "] autoscale
color_mode=D....



This worked :D. Now it works perfectly, the only problem is that it gives me
2 .tif files containing both channels inside. Instead of 2 files with 1
channel each.

Also, is it possible to add the function of adjust brigthness/contrast auto
to channel 1 after the z stacks are joinend? or to both channels if it is
not possible

Thank you so much for your help!



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

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