Hi,
I'm trying to write a macro where .nd2 images/file within a folder are opened, split into 2 channels, and merged into a single image and saved as a new merged file. When I use Bio-Format Importer to split the channels, it generates 2 images/channels named: "file_name" - C=0 "file_name" - C=1 Here's my macro code so far: path = getDirectory('Choose Directory'); filelist = getFileList(path); output = path+"MergedJPG"+File.separator; File.makeDirectory(output); setBatchMode(true); for (i=0; i< filelist.length; i++) { if (endsWith(filelist[i], ".nd2")) { name = path + filelist[i]; run("Bio-Formats Importer", "open= ["+name+"] color_mode=Default view=Hyperstack stack_order=XYCZT color_mode=Default split_channels"); red = filelist[i]+" - C=1"; green = filelist[i]+" - C=0"; run("Merge Channels...", "c1=["+red+"] c2=["+green+"] create"); saveAs("jpeg", output + filelist[i]); run("Close"); setBatchMode(false); } } It's almost there. When I run it, I choose the directory (in this case the folder "nd2" containing my .nd2 image files), it creates the MergedJPG folder fine, but then this window pops up and I still have to click on each .nd2 file with in my chosen folder, and in the right order, for each image to get processed and saved as the merged .jpg files. <http://imagej.1557.x6.nabble.com/file/t382408/Capturefuji.jpg> I assume I'm just missing some simple thing in order for it to actually automate and batch process all the .nd2 files in my chosen folder without me having to select each. Thanks for the help, YL -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
try to use
Ext.openImagePlus(path+filelist[i]); run("Split Channels"); instead of name = path + filelist[i]; run("Bio-Formats Importer", "open= ["+name+"] color_mode=Default view=Hyperstack stack_order=XYCZT color_mode=Default split_channels"); You have to check what the titles will be of the different channels after splitting them and adjusting your code accordingly. Hope this works Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester www.le.ac.uk/advanced-imaging-facility ________________________________________ -- Sent from: http://imagej.1557.x6.nabble.com/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Perhaps this could serve as a model for one way to solve the problem.
http://microscopynotes.com/imagej/macros/simplefigure/index.html Cheers- Michael Cammer, Sr Research Scientist, DART Microscopy Laboratory NYU Langone Health, 540 First Avenue, SK2 Microscopy Suite, New York, NY 10016 [hidden email]<mailto:[hidden email]> http://nyulmc.org/micros http://microscopynotes.com/ Voice direct only, no text or messages: 1-914-309-3270 and 1-646-501-0567 ________________________________ From: Krs5 <[hidden email]> Sent: Tuesday, August 6, 2019 3:49:46 AM To: [hidden email] Subject: Re: Macro for merging 2 channels of .nd2 files try to use Ext.openImagePlus(path+filelist[i]); run("Split Channels"); instead of name = path + filelist[i]; run("Bio-Formats Importer", "open= ["+name+"] color_mode=Default view=Hyperstack stack_order=XYCZT color_mode=Default split_channels"); You have to check what the titles will be of the different channels after splitting them and adjusting your code accordingly. Hope this works Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester https://urldefense.proofpoint.com/v2/url?u=http-3A__www.le.ac.uk_advanced-2Dimaging-2Dfacility&d=DwICAg&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=ivbeSXjq3_KWhZ8NKmF0R-LSI1Ex78fFwEHjXJNmpEU&s=pMb6EXqr9ndZI2_6XSYYI5xeiZ513Y0eetWIgCt_JbA&e= ________________________________________ -- Sent from: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.1557.x6.nabble.com_&d=DwICAg&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=ivbeSXjq3_KWhZ8NKmF0R-LSI1Ex78fFwEHjXJNmpEU&s=RcqRo83VG6idYU5bq6KDvUORax3EHEg_XeWVGNQZrJ4&e= -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DwICAg&c=j5oPpO0eBH1iio48DtsedeElZfc04rx3ExJHeIIZuCs&r=hUBj2D5n6oKThx2L01qn8IORZb5f-ruLVXPmQ1zQNnM&m=ivbeSXjq3_KWhZ8NKmF0R-LSI1Ex78fFwEHjXJNmpEU&s=a2C1oDY-AzMO8ChdY78ZGaGqLAY8dsA_Z7evPAfgboE&e= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |