Re: [micro-manager-general] Access live image from Matlab
Status: Beta
Brought to you by:
nicost
|
From: Kyle D. <kyl...@gm...> - 2018-06-19 17:52:37
|
Hi Vanessa, I did a bit more digging. It seems that accessing Java nested classes and enums (SaveMode is a nested enum) from within MATLAB requires a bit of trickery. According to this MATLAB Answers thread ( https://www.mathworks.com/matlabcentral/answers/15711-how-do-i-access-a-java-inner-class-from-matlab), you should be able to get the value encoded by MULTIPAGE_TIFF using MATLAB's javaMethod(...). Try the following: MULTIPAGE_TIFF = javaMethod('valueOf', 'org.micromanager.data.Datastore$SaveMode', 'MULTIPAGE_TIFF') (If that doesn't work, try changing the dollar sign to a period.) I think most of your difficulties are coming from how MATLAB accesses Java objects, but hopefully we can find a workaround. Best, Kyle On Tue, Jun 19, 2018, 18:48 Vanessa King <van...@gm...> wrote: > I've tried your suggestion of using the full package name, but this > continued to give the same error. I also tried importing > org.micromanager.data.Datastore.SaveMode prior to the save function, but > this failed as well. Matlab did not recognize it as a valid import > statement, saying that it was not a fully qualified class name. Just in > case, I also tried using the javaObject(...) method, but this gave an error > saying that org.micromanager.data.Datastore.SaveMode.MULTIPAGE_TIFF is not > on the Java class path. > > So it appears that this is an import issue. I double checked my static > Java class path, and it definitely contains all .jar files in the plugins > folder and the ij.jar from outside the plugins folder. My script currently > has no issue importing and using all of: > > import mmcorej.* > > import org.micromanager.data.Datastore; > > import org.micromanager.data.Image; > > import java.util.List; > > import org.micromanager.SnapLiveManager; > > I don't see why the class path to SaveMode cannot be found by Matlab but > the Datastore class path can be. Any more ideas as to what could be causing > this error or other options I could try would be greatly appreciated! > > Thanks, > Vanessa > > On Tue, Jun 19, 2018 at 6:37 AM, Kyle Douglass <kyl...@gm...> > wrote: > >> Hi Vanessa, >> >> On Mon, Jun 18, 2018 at 8:52 PM, Vanessa King <van...@gm...> >> wrote: >> >>> Thanks for the help Kyle, >>> >> >> You're welcome! >> >> >>> >>> However, I am now running into issues while trying to use the save the >>> datastore. Following the example from the version 2.0 How Do I... page, I >>> am using store.save(Datastore.SaveMode.MULTIPAGE_TIFF, savePath); >>> But this throws the error: >>> >>> Undefined function or variable 'SaveMode'. >>> >>> Error in Focus>pushbutton4_Callback (line 302) >>> store.save(Datastore.SaveMode.MULTIPAGE_TIFF, savePath); >>> >>> >> According to the Javadocs ( >> https://valelab4.ucsf.edu/~MM/doc-2.0.0-beta2/mmstudio/org/micromanager/data/Datastore.html), >> SaveMode is a static Java enum nested inside the Datastore class, so you >> shouldn't need to initialize it using MATLAB's javaObject(...) method. This >> means that the way you're using it in MATLAB appears correct. >> >> However according to this StackOverflow question ( >> https://stackoverflow.com/questions/1223795/using-java-enums-or-public-static-fields-in-matlab) >> it looks like you may need to access the enum constant named MULTIPAGE_TIFF >> using the full package name. Try changing Datastore.SaveMode.MULTIPAGE_TIFF >> to org.micromanager.data.Datastore.SaveMode.MULTIPAGE_TIFF. Or, try >> adding the import org.micromanager.data.Datastore; statement back to your >> script if you removed it from the last iteration. >> >> Write back if you make any progress. >> Cheers, >> Kyle >> >> >> >> ------------------------------------------------------------------------------ >> 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 >> mic...@li... >> https://lists.sourceforge.net/lists/listinfo/micro-manager-general >> >> > > ------------------------------------------------------------------------------ > 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 > mic...@li... > https://lists.sourceforge.net/lists/listinfo/micro-manager-general > |