Login  Register

Re: Save settings temporary

Posted by Michael Schmid on Nov 30, 2016; 7:28pm
URL: http://imagej.273.s1.nabble.com/question-on-stack-histogram-macro-tp5017654p5017665.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