Hello There,
I have a simple question on acquiring stack histogram. If I have a stack image named "raw", I can use "Analyze" --> "Histogram" to get the stack histogram. the ImageJ will show the histogram in a new window named "Histogram of raw". once I click the "List" button in the new window, it will show all the bins and counts in a table, then I can save teh table as a xls file. My question is how to achieve this in macro language. once I run selectImage("raw"); run("Histogram", "stack"); how do I open the stack histogram table ( as manully click the "List" button)? Thanks Lai -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Lai,
You need to use the getHistogram function described here : https://imagej.nih.gov/ij/developer/macro/functions.html#H *getHistogram(values, counts)* best, Thomas* * On 30/11/2016 10:32, Lai Ding wrote: > Hello There, > > I have a simple question on acquiring stack histogram. > > If I have a stack image named "raw", I can use "Analyze" --> "Histogram" to get the stack histogram. the ImageJ will show the histogram in a new window named "Histogram of raw". once I click the "List" button in the new window, it will show all the bins and counts in a table, then I can save teh table as a xls file. > > My question is how to achieve this in macro language. once I run > > selectImage("raw"); > run("Histogram", "stack"); > > how do I open the stack histogram table ( as manully click the "List" button)? > > Thanks > Lai > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- /***************************************************************/ Thomas Boudier, Associate Professor, UPMC, Université Pierre et Marie Curie, Paris, France. BioInformatics Institute (BII)/IPAL, Singapore. /**************************************************************/ -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by Lai Ding
Look at the getHistogram command at https://imagej.nih.gov/ij/developer/macro/functions.html#G .
Instead of run("Histogram", "stack"); use the getHistogram command. _________________________________________ Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/microscopy http://microscopynotes.com/ Cell: (914) 309-3270 ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of Lai Ding [[hidden email]] Sent: Tuesday, November 29, 2016 9:32 PM To: [hidden email] Subject: question on stack histogram macro Hello There, I have a simple question on acquiring stack histogram. If I have a stack image named "raw", I can use "Analyze" --> "Histogram" to get the stack histogram. the ImageJ will show the histogram in a new window named "Histogram of raw". once I click the "List" button in the new window, it will show all the bins and counts in a table, then I can save teh table as a xls file. My question is how to achieve this in macro language. once I run selectImage("raw"); run("Histogram", "stack"); how do I open the stack histogram table ( as manully click the "List" button)? Thanks Lai -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DgIFaQ&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=AHN5osRHyOzQygzzFuvZwdLQvPqIKmsjnoUGd8iVVsk&s=ZsBAYErVU7YKf7UKzTQ5M19kKJzb2hUcUyO18IYVaMw&e= ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Thanks for everyone's input.
The getHistogram() can only get info from a single slice. For the stack image, I realize the sample code of "StackHistogramLister" can be modified for my purpose. https://imagej.nih.gov/ij/macros/StackHistogramLister.txt However, I feel since the run("Histogram", "stack") already have the histogram of the whole stack, there may be a simple way to retrieve the information rather than redo the whole thing through macro codes. Best Lai -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Cammer, Michael Sent: Tuesday, November 29, 2016 9:40 PM To: [hidden email] Subject: Re: question on stack histogram macro Look at the getHistogram command at https://imagej.nih.gov/ij/developer/macro/functions.html#G . Instead of run("Histogram", "stack"); use the getHistogram command. _________________________________________ Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/microscopy http://microscopynotes.com/ Cell: (914) 309-3270 ________________________________________ From: ImageJ Interest Group [[hidden email]] on behalf of Lai Ding [[hidden email]] Sent: Tuesday, November 29, 2016 9:32 PM To: [hidden email] Subject: question on stack histogram macro Hello There, I have a simple question on acquiring stack histogram. If I have a stack image named "raw", I can use "Analyze" --> "Histogram" to get the stack histogram. the ImageJ will show the histogram in a new window named "Histogram of raw". once I click the "List" button in the new window, it will show all the bins and counts in a table, then I can save teh table as a xls file. My question is how to achieve this in macro language. once I run selectImage("raw"); run("Histogram", "stack"); how do I open the stack histogram table ( as manully click the "List" button)? Thanks Lai -- ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http-3A__imagej.nih.gov_ij_list.html&d=DgIFaQ&c=j5oPpO0eBH1iio48DtsedbOBGmuw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=AHN5osRHyOzQygzzFuvZwdLQvPqIKmsjnoUGd8iVVsk&s=ZsBAYErVU7YKf7UKzTQ5M19kKJzb2hUcUyO18IYVaMw&e= ------------------------------------------------------------ This email message, including any attachments, is for the sole use of the intended recipient(s) and may contain information that is proprietary, confidential, and exempt from disclosure under applicable law. Any unauthorized review, use, disclosure, or distribution is prohibited. If you have received this email in error please notify the sender by return email and delete the original message. Please note, the recipient should check this email and any attachments for the presence of viruses. The organization accepts no liability for any damage caused by any virus transmitted by this email. ================================= -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Dear List,
I've would like to save some settings of an imagej macro until ImageJ is restarted. To be more precise: I want to apply a macro and safe the settings. If the macro is applied again then it uses the saved settings. When ImageJ is restarted the saved settings should be dismissed. Any ideas? Best, Thorsten Am Mittwoch, den 30.11.2016, 14:11 +0000 schrieb Ding, Lai: > Thanks for everyone's input. > > The getHistogram() can only get info from a single slice. For the > stack image, I realize the sample code of "StackHistogramLister" can > be modified for my purpose. > > https://imagej.nih.gov/ij/macros/StackHistogramLister.txt > > However, I feel since the run("Histogram", "stack") already have the > histogram of the whole stack, there may be a simple way to retrieve > the information rather than redo the whole thing through macro codes. > > Best > Lai > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Cammer, Michael > Sent: Tuesday, November 29, 2016 9:40 PM > To: [hidden email] > Subject: Re: question on stack histogram macro > > Look at the getHistogram command at https://imagej.nih.gov/ij/develop > er/macro/functions.html#G . > > Instead of run("Histogram", "stack"); use the getHistogram command. > > _________________________________________ > Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/ > microscopy http://microscopynotes.com/ > Cell: (914) 309-3270 > > ________________________________________ > From: ImageJ Interest Group [[hidden email]] on behalf of Lai > Ding [[hidden email]] > Sent: Tuesday, November 29, 2016 9:32 PM > To: [hidden email] > Subject: question on stack histogram macro > > Hello There, > > I have a simple question on acquiring stack histogram. > > If I have a stack image named "raw", I can use "Analyze" --> > "Histogram" to get the stack histogram. the ImageJ will show the > histogram in a new window named "Histogram of raw". once I click the > "List" button in the new window, it will show all the bins and counts > in a table, then I can save teh table as a xls file. > > My question is how to achieve this in macro language. once I run > > selectImage("raw"); > run("Histogram", "stack"); > > how do I open the stack histogram table ( as manully click the > "List" button)? > > Thanks > Lai > > -- > ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http- > 3A__imagej.nih.gov_ij_list.html&d=DgIFaQ&c=j5oPpO0eBH1iio48DtsedbOBGm > uw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=AHN > 5osRHyOzQygzzFuvZwdLQvPqIKmsjnoUGd8iVVsk&s=ZsBAYErVU7YKf7UKzTQ5M19kKJ > zb2hUcUyO18IYVaMw&e= > > ------------------------------------------------------------ > This email message, including any attachments, is for the sole use of > the intended recipient(s) and may contain information that is > proprietary, confidential, and exempt from disclosure under > applicable law. Any unauthorized review, use, disclosure, or > distribution is prohibited. If you have received this email in error > please notify the sender by return email and delete the original > message. Please note, the recipient should check this email and any > attachments for the presence of viruses. The organization accepts no > liability for any damage caused by any virus transmitted by this > email. > ================================= > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Hi Thorsten,
you can write to the Preferences file in a macro. It is not obvious, because it uses a call to the respective Java function. The prefs file saves the values as Strings, but you can convert them from/to numbers: //write: call("ij.Prefs.set", "myMacros.myValue",toString(myVariable)); //read (with default 999): myVariable = parseInt(call("ij.Prefs.get", "myMacros.myValue","999")); (mind possible line breaks introduced by the mailer) This will keep the values when you restart ImageJ, but you could have the StartupMacros reset the value to some default. For this, have an "AutoRun" macro in the StartupMacros: macro "AutoRun" { defaultValue = -1; call("ij.Prefs.set", "myMacros.myValue",toString(defaultValue)); } Michael ________________________________________________________________ On 2016-11-30 15:34, Thorsten Wagner wrote: > Dear List, > > I've would like to save some settings of an imagej macro until ImageJ > is restarted. > > To be more precise: > > I want to apply a macro and safe the settings. If the macro is applied > again then it uses the saved settings. When ImageJ is restarted the > saved settings should be dismissed. > > Any ideas? > > Best, > Thorsten > Am Mittwoch, den 30.11.2016, 14:11 +0000 schrieb Ding, Lai: >> Thanks for everyone's input. >> >> The getHistogram() can only get info from a single slice. For the >> stack image, I realize the sample code of "StackHistogramLister" can >> be modified for my purpose. >> >> https://imagej.nih.gov/ij/macros/StackHistogramLister.txt >> >> However, I feel since the run("Histogram", "stack") already have the >> histogram of the whole stack, there may be a simple way to retrieve >> the information rather than redo the whole thing through macro codes. >> >> Best >> Lai >> >> -----Original Message----- >> From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of >> Cammer, Michael >> Sent: Tuesday, November 29, 2016 9:40 PM >> To: [hidden email] >> Subject: Re: question on stack histogram macro >> >> Look at the getHistogram command at https://imagej.nih.gov/ij/develop >> er/macro/functions.html#G . >> >> Instead of run("Histogram", "stack"); use the getHistogram command. >> >> _________________________________________ >> Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/ >> microscopy http://microscopynotes.com/ >> Cell: (914) 309-3270 >> >> ________________________________________ >> From: ImageJ Interest Group [[hidden email]] on behalf of Lai >> Ding [[hidden email]] >> Sent: Tuesday, November 29, 2016 9:32 PM >> To: [hidden email] >> Subject: question on stack histogram macro >> >> Hello There, >> >> I have a simple question on acquiring stack histogram. >> >> If I have a stack image named "raw", I can use "Analyze" --> >> "Histogram" to get the stack histogram. the ImageJ will show the >> histogram in a new window named "Histogram of raw". once I click the >> "List" button in the new window, it will show all the bins and counts >> in a table, then I can save teh table as a xls file. >> >> My question is how to achieve this in macro language. once I run >> >> selectImage("raw"); >> run("Histogram", "stack"); >> >> how do I open the stack histogram table ( as manully click the >> "List" button)? >> >> Thanks >> Lai >> >> -- >> ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http- >> 3A__imagej.nih.gov_ij_list.html&d=DgIFaQ&c=j5oPpO0eBH1iio48DtsedbOBGm >> uw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=AHN >> 5osRHyOzQygzzFuvZwdLQvPqIKmsjnoUGd8iVVsk&s=ZsBAYErVU7YKf7UKzTQ5M19kKJ >> zb2hUcUyO18IYVaMw&e= >> >> ------------------------------------------------------------ >> This email message, including any attachments, is for the sole use of >> the intended recipient(s) and may contain information that is >> proprietary, confidential, and exempt from disclosure under >> applicable law. Any unauthorized review, use, disclosure, or >> distribution is prohibited. If you have received this email in error >> please notify the sender by return email and delete the original >> message. Please note, the recipient should check this email and any >> attachments for the presence of viruses. The organization accepts no >> liability for any damage caused by any virus transmitted by this >> email. >> ================================= >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html >> >> -- >> ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
In reply to this post by jumpfunky
Dear Thorsten,
I have not tested this but you can save the settings in a file. When you start ImageJ you check if the file exists or if there is a file in a specific directory and if it does, you delete it using File.delete(path). This code to check for the file you can run via the option Edit > Option > Startup... what runs this macro code when ImageJ starts up. You could also just delete the file in the Startup code and make for the first time an empty file so you don't get an error that the file does not exist. Best wishes Kees Dr Ir K.R. Straatman Senior Experimental Officer Advanced Imaging Facility Centre for Core Biotechnology Services University of Leicester http://www2.le.ac.uk/colleges/medbiopsych/facilities-and-services/cbs/lite/aif -----Original Message----- From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of Thorsten Wagner Sent: 30 November 2016 14:34 To: [hidden email] Subject: Save settings temporary Dear List, I've would like to save some settings of an imagej macro until ImageJ is restarted. To be more precise: I want to apply a macro and safe the settings. If the macro is applied again then it uses the saved settings. When ImageJ is restarted the saved settings should be dismissed. Any ideas? Best, Thorsten Am Mittwoch, den 30.11.2016, 14:11 +0000 schrieb Ding, Lai: > Thanks for everyone's input. > > The getHistogram() can only get info from a single slice. For the > stack image, I realize the sample code of "StackHistogramLister" can > be modified for my purpose. > > https://imagej.nih.gov/ij/macros/StackHistogramLister.txt > > However, I feel since the run("Histogram", "stack") already have the > histogram of the whole stack, there may be a simple way to retrieve > the information rather than redo the whole thing through macro codes. > > Best > Lai > > -----Original Message----- > From: ImageJ Interest Group [mailto:[hidden email]] On Behalf Of > Cammer, Michael > Sent: Tuesday, November 29, 2016 9:40 PM > To: [hidden email] > Subject: Re: question on stack histogram macro > > Look at the getHistogram command at https://imagej.nih.gov/ij/develop > er/macro/functions.html#G . > > Instead of run("Histogram", "stack"); use the getHistogram command. > > _________________________________________ > Michael Cammer, Optical Microscopy Specialist http://ocs.med.nyu.edu/ > microscopy http://microscopynotes.com/ > Cell: (914) 309-3270 > > ________________________________________ > From: ImageJ Interest Group [[hidden email]] on behalf of Lai > Ding [[hidden email]] > Sent: Tuesday, November 29, 2016 9:32 PM > To: [hidden email] > Subject: question on stack histogram macro > > Hello There, > > I have a simple question on acquiring stack histogram. > > If I have a stack image named "raw", I can use "Analyze" --> > "Histogram" to get the stack histogram. the ImageJ will show the > histogram in a new window named "Histogram of raw". once I click the > "List" button in the new window, it will show all the bins and counts > in a table, then I can save teh table as a xls file. > > My question is how to achieve this in macro language. once I run > > selectImage("raw"); > run("Histogram", "stack"); > > how do I open the stack histogram table ( as manully click the "List" > button)? > > Thanks > Lai > > -- > ImageJ mailing list: https://urldefense.proofpoint.com/v2/url?u=http- > 3A__imagej.nih.gov_ij_list.html&d=DgIFaQ&c=j5oPpO0eBH1iio48DtsedbOBGm > uw5jHLjgvtN2r4ehE&r=oU_05LztNstAydlbm5L5GDu_vAdjXk3frDLx_CqKkuo&m=AHN > 5osRHyOzQygzzFuvZwdLQvPqIKmsjnoUGd8iVVsk&s=ZsBAYErVU7YKf7UKzTQ5M19kKJ > zb2hUcUyO18IYVaMw&e= > > ------------------------------------------------------------ > This email message, including any attachments, is for the sole use of > the intended recipient(s) and may contain information that is > proprietary, confidential, and exempt from disclosure under applicable > law. Any unauthorized review, use, disclosure, or distribution is > prohibited. If you have received this email in error please notify the > sender by return email and delete the original message. Please note, > the recipient should check this email and any attachments for the > presence of viruses. The organization accepts no liability for any > damage caused by any virus transmitted by this email. > ================================= > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html > > -- > ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html -- ImageJ mailing list: http://imagej.nih.gov/ij/list.html |
Free forum by Nabble | Edit this page |