How to open saved acquisitions?

classic Classic list List threaded Threaded
8 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

How to open saved acquisitions?

phsiao
Hi, I have a acquisition saved on disk as a .tif file.
What function I should use to retrieve those images back in MM by using BeanShell?

I tried

acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35/etl_45_to_25_step_0_5_best_at_35_MMStack_Pos0.ome.tif";
gui.openAcquisitionData(acq_data, true);

but have a "run-time error : MMScript error: null" error.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

Kyle Douglass
Dear Joe,


On 03/21/2017 03:47 PM, phsiao wrote:
> Hi, I have a acquisition saved on disk as a .tif file.
> What function I should use to retrieve those images back in MM by using
> BeanShell?
>

Below is a quick MM 2.0 gist for opening acquisitions that have been
saved to disk. It opens the data as a virtual stack and prints the
number of images in them (just as an example).

If you want to display the images, I believe you need to connect the
Datastore object returned by loadData() to a DisplayManager, but perhaps
someone else can better inform you about this than I.

Cheers,
Kyle

String folder = "/path/to/data";
openAsVirtualStack = true;

// mm.data() returns a reference to the DefaultDataManager
datastore = mm.data().loadData(folder, openAsVirtualStack);

print("Number of images: " + String.valueOf(datastore.getNumImages()));


--
Kyle M. Douglass, PhD
Post-doctoral researcher
The Laboratory of Experimental Biophysics
EPFL, Lausanne, Switzerland
http://kmdouglass.github.io
http://leb.epfl.ch


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

JonD
Administrator
In reply to this post by phsiao
phsiao wrote
I tried

acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35/etl_45_to_25_step_0_5_best_at_35_MMStack_Pos0.ome.tif";
gui.openAcquisitionData(acq_data, true);

but have a "run-time error : MMScript error: null" error.
I think you need to drop the tif file from the path and just point MM at the directory, like this:

acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35";
gui.openAcquisitionData(acq_data, true);

Jon

-------------------------------------------
Jon Daniels
Applied Scientific Instrumentation
29391 West Enid Rd, Eugene, OR 97402
Phone: (541) 461-8181 x118
-------------------------------------------
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

phsiao
JonD wrote
phsiao wrote
I tried

acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35/etl_45_to_25_step_0_5_best_at_35_MMStack_Pos0.ome.tif";
gui.openAcquisitionData(acq_data, true);

but have a "run-time error : MMScript error: null" error.
I think you need to drop the tif file from the path and just point MM at the directory, like this:

acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35";
gui.openAcquisitionData(acq_data, true);

Jon

-------------------------------------------
Jon Daniels
Applied Scientific Instrumentation
29391 West Enid Rd, Eugene, OR 97402
Phone: (541) 461-8181 x118
-------------------------------------------
This works!

Do you know how to access individual images from the stack?

The API shows:

/**
    * Open an existing data set. Shows the acquisition in a window.
    * @return The acquisition object.
    */
   public String openAcquisitionData(String location, boolean inRAM) throws MMScriptException;

How come an acquisition object is String type??
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

Nico Stuurman-2

On 3/21/17 10:17 AM, phsiao wrote:

> JonD wrote
>> phsiao wrote
>>> I tried
>>>
>>> acq_data =
>>> "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35/etl_45_to_25_step_0_5_best_at_35_MMStack_Pos0.ome.tif";
>>> gui.openAcquisitionData(acq_data, true);
>>>
>>> but have a "run-time error : MMScript error: null" error.
>> I think you need to drop the tif file from the path and just point MM at
>> the directory, like this:
>>
>> acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35";
>> gui.openAcquisitionData(acq_data, true);
>>
>>
> This works!
>
> Do you know how to access individual images from the stack?
>
> The API shows:
>
> /**
>      * Open an existing data set. Shows the acquisition in a window.
>      * @return The acquisition object.
>      */
>     public String openAcquisitionData(String location, boolean inRAM) throws
> MMScriptException;
>
> How come an acquisition object is String type??

Since you are just starting out to develop scripts for Micro-Manager,
please switch to using 2.0.  It is a much better thought out api that
should make your life easier.  Moreover, 1.4 is already in maintenance
mode, and you can not expect any new features or additions there.  
Accessing individual image from the stack is very easy in 2.0 , and a
complete hack in 1.4 (you will have to go through ImageJ classes, and
interpretation of what image is which is dubious at best).

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

JonD
Administrator
In reply to this post by phsiao
phsiao wrote
Do you know how to access individual images from the stack?
Something like this:

import ij.IJ;
import ij.ImagePlus;
import org.micromanager.api.MMWindow;
import ij.process.ImageProcessor;

ImagePlus ip = IJ.getImage();
// gets the top-most ImageJ window, including a MM dataset
// you could probably do a lot of manipulations directly from this ImagePlus object using the ImageJ API

MMWindow mmW = new MMWindow(ip);
// may not fully work if a non-MM dataset windows was the source of the ImagePlus object above, you can test with mmW.isMMWindow()

ImageProcessor iproc = mmW.getImageProcessor(0, 0, 0, 1);
// get the first image using method with signature ImageProcessor getImageProcessor(int channel, int slice, int frame, int position)
//   where all are zero-indexed except position which is 1-indexed according to javadoc in MMWindow.java
// see MMWindow.java file in /mmstudio/api for other available methods

phsiao wrote
The API shows:

/**
    * Open an existing data set. Shows the acquisition in a window.
    * @return The acquisition object.
    */
   public String openAcquisitionData(String location, boolean inRAM) throws MMScriptException;

How come an acquisition object is String type??
I'm not sure but it seems in MM1.4 the acquisition had a string "key" that is used to refer to it internally.  This may very well be different in MM2.

Jon

-------------------------------------------
Jon Daniels
Applied Scientific Instrumentation
29391 West Enid Rd, Eugene, OR 97402
Phone: (541) 461-8181 x118
-------------------------------------------
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

phsiao
In reply to this post by Nico Stuurman-2
Nico Stuurman-2 wrote
On 3/21/17 10:17 AM, phsiao wrote:
> JonD wrote
>> phsiao wrote
>>> I tried
>>>
>>> acq_data =
>>> "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35/etl_45_to_25_step_0_5_best_at_35_MMStack_Pos0.ome.tif";
>>> gui.openAcquisitionData(acq_data, true);
>>>
>>> but have a "run-time error : MMScript error: null" error.
>> I think you need to drop the tif file from the path and just point MM at
>> the directory, like this:
>>
>> acq_data = "C:/Users/phsiao/Desktop/etl_45_to_25_step_0_5_best_at_35";
>> gui.openAcquisitionData(acq_data, true);
>>
>>
> This works!
>
> Do you know how to access individual images from the stack?
>
> The API shows:
>
> /**
>      * Open an existing data set. Shows the acquisition in a window.
>      * @return The acquisition object.
>      */
>     public String openAcquisitionData(String location, boolean inRAM) throws
> MMScriptException;
>
> How come an acquisition object is String type??

Since you are just starting out to develop scripts for Micro-Manager,
please switch to using 2.0.  It is a much better thought out api that
should make your life easier.  Moreover, 1.4 is already in maintenance
mode, and you can not expect any new features or additions there.  
Accessing individual image from the stack is very easy in 2.0 , and a
complete hack in 1.4 (you will have to go through ImageJ classes, and
interpretation of what image is which is dubious at best).

Best,

Nico


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
micro-manager-general mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/micro-manager-general
Good to know. Unfortunately I have other scripts and plugins written in 1.4 so I have to stick with it for now. I will consider the switch in the future.
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How to open saved acquisitions?

phsiao
In reply to this post by JonD
JonD wrote
phsiao wrote
Do you know how to access individual images from the stack?
Something like this:

import ij.IJ;
import ij.ImagePlus;
import org.micromanager.api.MMWindow;
import ij.process.ImageProcessor;

ImagePlus ip = IJ.getImage();
// gets the top-most ImageJ window, including a MM dataset
// you could probably do a lot of manipulations directly from this ImagePlus object using the ImageJ API

MMWindow mmW = new MMWindow(ip);
// may not fully work if a non-MM dataset windows was the source of the ImagePlus object above, you can test with mmW.isMMWindow()

ImageProcessor iproc = mmW.getImageProcessor(0, 0, 0, 1);
// get the first image using method with signature ImageProcessor getImageProcessor(int channel, int slice, int frame, int position)
//   where all are zero-indexed except position which is 1-indexed according to javadoc in MMWindow.java
// see MMWindow.java file in /mmstudio/api for other available methods

phsiao wrote
The API shows:

/**
    * Open an existing data set. Shows the acquisition in a window.
    * @return The acquisition object.
    */
   public String openAcquisitionData(String location, boolean inRAM) throws MMScriptException;

How come an acquisition object is String type??
I'm not sure but it seems in MM1.4 the acquisition had a string "key" that is used to refer to it internally.  This may very well be different in MM2.

Jon

-------------------------------------------
Jon Daniels
Applied Scientific Instrumentation
29391 West Enid Rd, Eugene, OR 97402
Phone: (541) 461-8181 x118
-------------------------------------------
Jon this works well. Thank you!
Loading...