Quantcast

How for force MDA saving separate stacks for each position using Java

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

How for force MDA saving separate stacks for each position using Java

Doug Wood
Hi All,

I am writing a plugin in Java that uses the MDA and we are having trouble getting our data saved correctly if users change some settings in the Micromanager GUI. I would like to force certain settings when my plugin is controlling acquistions.  I have been able to do this with many settings in the MDA, but I am at a loss as to how to force the MDA to set preferences so that a separate image stack (with multiple channels) is saved for each position in the position list.  It seems like two things need to be set correctly for this to happen: the check box "Save XY positions in separate Image Stack Files" in the Micro-Manager options dialog must be checked, AND the radio button "Image stack files" in the MDA dialog must be selected.

Here is a screen shot showing what I am talking about:



My question is this: How to I force these options when running MDA from a plugin?


Here is a snippet of code where I would like to insert this:
                AcquisitionWrapperEngine engine = MMStudio.getInstance().getAcquisitionEngine();
                MMStudio studio = MMStudio.getInstance();
                SequenceSettings settings = app.getAcquisitionSettings();
                boolean saveSeparateFiles = studio.getSeparateFilesForPositionsMPTiff();
                engine.setSaveFiles(true);
                engine.setSequenceSettings(settings);

I put in bold a method call I can make to GET what seems to be one of the settings, but I do not see a corresponding setter for this.  I am unable to find a getter or setter for the Save XY positions in separate Image Stack Files in the MDA.  Sorry if I am missing something obvious.

BTW, I am successfully doing things like this:
        void setMDARootDirectory(String pathName) {
                SequenceSettings settings = app_.getAcquisitionSettings();
                settings.root = pathName;
                app_.setAcquisitionSettings(settings);
        }
to force changes in setting the root directory, for example. I just can't find where one would set the two options I need to force saving a separate TIFF stack (in this case a stack with 3 channels) at each XY position.

If you have any knowledge about how to set either of these, please let me know how it is done.

Your help is MUCH appreciated!
-Doug




Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: How for force MDA saving separate stacks for each position using Java

Nico Stuurman-2
Hi Doug,


On 5/8/17 10:09 AM, Doug Wood wrote:

> I am writing a plugin in Java that uses the MDA and we are having trouble
> getting our data saved correctly if users change some settings in the
> Micromanager GUI. I would like to force certain settings when my plugin is
> controlling acquistions.  I have been able to do this with many settings in
> the MDA, but I am at a loss as to how to force the MDA to set preferences so
> that a separate image stack (with multiple channels) is saved for each
> position in the position list.  It seems like two things need to be set
> correctly for this to happen: the check box "Save XY positions in separate
> Image Stack Files" in the Micro-Manager options dialog must be checked, AND
> the radio button "Image stack files" in the MDA dialog must be selected.
>
> Here is a screen shot showing what I am talking about:
> <http://micro-manager.3463995.n2.nabble.com/file/n7588388/Tiff_file_saving_preferences.png>
>
> *
> /My question is this: How to I force these options when running MDA from a
> plugin?/*
>
> Here is a snippet of code where I would like to insert this:
> AcquisitionWrapperEngine engine =
> MMStudio.getInstance().getAcquisitionEngine();
> MMStudio studio = MMStudio.getInstance();
> SequenceSettings settings = app.getAcquisitionSettings();
> *boolean saveSeparateFiles = studio.getSeparateFilesForPositionsMPTiff();*
> engine.setSaveFiles(true);
> engine.setSequenceSettings(settings);
>
> I put in bold a method call I can make to /GET/ what seems to be one of the
> settings, but I do not see a corresponding setter for this.  I am unable to
> find a getter or setter for the Save XY positions in separate Image Stack
> Files in the MDA.  Sorry if I am missing something obvious.
>
> BTW, I am successfully doing things like this:
> void setMDARootDirectory(String pathName) {
> SequenceSettings settings = app_.getAcquisitionSettings();
> settings.root = pathName;
> app_.setAcquisitionSettings(settings);
> }
> to force changes in setting the root directory, for example. I just can't
> find where one would set the two options I need to force saving a separate
> TIFF stack (in this case a stack with 3 channels) at each XY position.
>
> If you have any knowledge about how to set either of these, please let me
> know how it is done.

All of this is very ugly (and much improved in the 2.0 api).  To make MM
1.4 use "Image stack files", use:

ImageUtils.setImageStorageClass(TaggedImageStorageMultipageTiff.class);

Saving XY positions in separate Image Stack Files is stored in a private
instance of MMOptions in MMStudio.  You would need to use introspection
to get access to it and then set the field
mpTiffSeparateFilesForPositions_.

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 for force MDA saving separate stacks for each position using Java

Doug Wood
In reply to this post by Doug Wood
Thanks Nico!

I followed your suggestions and this seems to work:

// Force saving a separate TIFF stack at each position, one plane for each channel
        private void forceTIFFileSettings() {
                // This has the effect of setting the radio button "Image Stack File" in the MDA dialog
                ImageUtils.setImageStorageClass(TaggedImageStorageMultipageTiff.class);
                // The check box "Save XY positions in separate Image Stack Files" requires introspection (!)
                // (thanks to Nico on the micromanager forum for help with this on 5/8/17)
                try {
                    MMStudio studio = MMStudio.getInstance();
                    Field optionsField = studio.getClass().getDeclaredField("options_");
                    optionsField.setAccessible(true);
                    Object optionsObj = optionsField.get(studio);
                    Field separateTiffForPositionsField = optionsObj.getClass().getDeclaredField("mpTiffSeparateFilesForPositions_");
                    separateTiffForPositionsField.setBoolean(optionsObj, true);
                } catch (NoSuchFieldException x) {
                    x.printStackTrace();
                } catch (IllegalAccessException x) {
                    x.printStackTrace();
                }
        }

Cheers,
Doug
Loading...