Quantcast

how to set calibration in API

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

how to set calibration in API

Aryeh Weiss
I wrote a python script to import my AFM image files, and it works
great. These are small text images, with some metadata prepended, so I
used this example as a starting point:

http://imagej.net/Jython_Scripting_Examples#Creating_an_image_from_a_text_file

However, one of the things that I want to do is to set the spatial
calibration of the imported image.
Right now I am doing it this way:
IJ.run(imp, "Properties...", "channels=1 slices=1 frames=1 unit=micron
pixel_width="+str(xCal)+" pixel_height="+str(yCal)+" voxel_depth=1.0000")

where xCal and yCal are previously found from the metadata.

There must be a way to do it without this call to IJ.run

I thought to use the Calibration class:
https://imagej.nih.gov/ij/developer/api/ij/measure/Calibration.html

and this let me set the units, but I did not see a method here to change
the value of the calibration.

ImagePlus has setProperty(java.lang.String key, java.lang.Object value)

but for this I need to know the name of the key (which I suppose I can
get from the popup window of the Properties... command).

So my questions are:

1. What is the correct way to do this?

2. If setProperty() is the way to go, where in the API can I find a list
of the predefined properties?

Thank is advance.

--aryeh

--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051


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

Re: how to set calibration in API

Michael Schmid-3
Hi Aryeh,

many variables of the Calibration class are public, so you can simply
read and write the variables without getVariable or setVariable methods.

Look at
   https://github.com/imagej/imagej1/blob/master/ij/measure/Calibration.java


Michael
________________________________________________________________
On 09/05/2017 15:23, Aryeh Weiss wrote:

> I wrote a python script to import my AFM image files, and it works
> great. These are small text images, with some metadata prepended, so I
> used this example as a starting point:
>
> http://imagej.net/Jython_Scripting_Examples#Creating_an_image_from_a_text_file
>
>
> However, one of the things that I want to do is to set the spatial
> calibration of the imported image.
> Right now I am doing it this way:
> IJ.run(imp, "Properties...", "channels=1 slices=1 frames=1 unit=micron
> pixel_width="+str(xCal)+" pixel_height="+str(yCal)+" voxel_depth=1.0000")
>
> where xCal and yCal are previously found from the metadata.
>
> There must be a way to do it without this call to IJ.run
>
> I thought to use the Calibration class:
> https://imagej.nih.gov/ij/developer/api/ij/measure/Calibration.html
>
> and this let me set the units, but I did not see a method here to change
> the value of the calibration.
>
> ImagePlus has setProperty(java.lang.String key, java.lang.Object value)
>
> but for this I need to know the name of the key (which I suppose I can
> get from the popup window of the Properties... command).
>
> So my questions are:
>
> 1. What is the correct way to do this?
>
> 2. If setProperty() is the way to go, where in the API can I find a list
> of the predefined properties?
>
> Thank is advance.
>
> --aryeh
>

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

Re: how to set calibration in API

Aryeh Weiss
In reply to this post by Aryeh Weiss
Hi Michael,

On 09/05/2017 18:48, Michael Schmid wrote:
> Hi Aryeh,
>
> many variables of the Calibration class are public, so you can simply
> read and write the variables without getVariable or setVariable methods.
>
> Look at
> https://github.com/imagej/imagej1/blob/master/ij/measure/Calibration.java
>

Perfect -- thank you for your quick reply.
Now it looks like this:

units = "micron"

newCal = Calibration()
newCal.pixelWidth = xCal
newCal.pixelHeight = yCal
newCal.setXUnit(units)
newCal.setYUnit(units)
imp.setCalibration(newCal)


--aryeh

>
> Michael
> ________________________________________________________________
> On 09/05/2017 15:23, Aryeh Weiss wrote:
>> I wrote a python script to import my AFM image files, and it works
>> great. These are small text images, with some metadata prepended, so I
>> used this example as a starting point:
>>
>> http://imagej.net/Jython_Scripting_Examples#Creating_an_image_from_a_text_file 
>>
>>
>>
>> However, one of the things that I want to do is to set the spatial
>> calibration of the imported image.
>> Right now I am doing it this way:
>> IJ.run(imp, "Properties...", "channels=1 slices=1 frames=1 unit=micron
>> pixel_width="+str(xCal)+" pixel_height="+str(yCal)+"
>> voxel_depth=1.0000")
>>
>> where xCal and yCal are previously found from the metadata.
>>
>> There must be a way to do it without this call to IJ.run
>>
>> I thought to use the Calibration class:
>> https://imagej.nih.gov/ij/developer/api/ij/measure/Calibration.html
>>
>> and this let me set the units, but I did not see a method here to change
>> the value of the calibration.
>>
>> ImagePlus has setProperty(java.lang.String key, java.lang.Object value)
>>
>> but for this I need to know the name of the key (which I suppose I can
>> get from the popup window of the Properties... command).
>>
>> So my questions are:
>>
>> 1. What is the correct way to do this?
>>
>> 2. If setProperty() is the way to go, where in the API can I find a list
>> of the predefined properties?
>>
>> Thank is advance.
>>
>> --aryeh
>>
>


--
Aryeh Weiss
Faculty of Engineering
Bar Ilan University
Ramat Gan 52900 Israel

Ph:  972-3-5317638
FAX: 972-3-7384051

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