Matlab utility functions #56

Merged
merged 11 commits into from Apr 26, 2012

4 participants

@sbesson
Open Microscopy Environment member

Improve utility functions so that high-level Matlab functions can be used as painlessly as possible.
In particular create a function to check/add loci_tools.jar in the Java class path.

Testing scenarios

For all tests, make sure loci_tools.jar is in the Matlab path, restart Matlab (clear all paths) and perform the test twice.
NB: to use runtests, you need the xUnit test framework for Matlab to be installed and added to the path (http://www.mathworks.com/matlabcentral/fileexchange/22846-matlab-xunit-test-framework)

  1. Add loci_tools.jar to Matlab static Java class path (using edit classpath.txt) and restart

    1. Run bfopen: should work
    2. Run r=bfGetReader(/path/to/file): return r
    3. Run TestCheckJavaPath with runtests: all tests should pass
  2. Remove loci_tools.jar from the Matlab static Java class path and restart

    1. Set autoloadBioformats=0 in bfopen.m and run bfopen: should fail with an informative error messaage
    2. Set autoloadBioformats=1 in bfopen.m and run bfopen: should work
    3. Run r=bfGetReader(/path/to/file): return r
    4. Run TestCheckJavaPath with runtests: all tests should pass
  3. Run tic; bfCheckJavaPath(); toc. Check the completion time is less than .2 s.

@sbesson
Open Microscopy Environment member

Note: this PR should address an issue raised by @ctrueden in the ome-users mailing list:
http://lists.openmicroscopy.org.uk/pipermail/ome-users/2012-April/003017.html

@melissalinkert
Open Microscopy Environment member

With loci_tools.jar on the static classpath:

>> bfopen
Error using bfopen (line 116)
Not enough input arguments.

>> bfopen('/home/melissa/test_images_good/al3d/Iron Plate.al3d');
Error using bfGetReader (line 22)
Argument 'debug' failed validation islogical.

Error in bfopen (line 116)
r=bfGetReader(id,stitchFiles);

The 'bfGetReader' and 'runtests' commands both work as I would expect.

With loci_tools.jar removed from the static classpath:

Changing the value of 'autoloadBioformats' works as expected, but running 'bfopen' still fails as above. 'bfGetReader' and 'runtests TestCheckJavaPath' both work as expected.

The timing test doesn't work as described above:

>> tic; bfCheckPath(); toc
Undefined function or variable 'bfCheckPath'.

...but assuming that was just a typo, this works:

>> tic; bfCheckJavaPath(); toc
Elapsed time is 0.166843 seconds.

A couple of additional requests:

  • I don't see any documentation that xUnit is required to run the tests- I know this from talking to you @sbesson, but others might not.
  • Could TestCheckJavaPath.m be moved to components/bio-formats/test/utils? I'd like to keep all of the tests under one directory, if possible.
  • As noted above, 'bfopen' with no arguments no longer works. It used to be that that would pop up a file chooser window (per request of a few different users). Could that behavior be restored, and maybe added to bfGetReader as well?
@ctrueden
Open Microscopy Environment member

Could TestCheckJavaPath.m be moved to components/bio-formats/test/utils? I'd like to keep all of the tests under one directory, if possible.

As long as files are being moved around, perhaps it is time to put the MATLAB code somewhere better than "utils" now that it is more than one .m file. Ideally I would say "components/bio-formats/src/main/matlab" and "components/bio-formats/src/test/matlab" but we're not using Maven conventions for anything else so perhaps just "components/bio-formats/matlab" is OK.

@sbesson
Open Microscopy Environment member

@melissalinkert,

  • Commits above should fix the first bug (bfopen with no argument).
  • Concerning the second bug (bfopen('file)), there should not be any 'debug' option. Is your bfGetReader shadowed by the one existing in the LCCB SVN repository by any chance? which bfGetReader -all
  • I extracted the getFileExtensions subfunction so that bfGetRedear can be called with no input argument as well.

I added notes in the PR regarding the usage of xUnit. Should I also insert references in each TestCase instantiation?

Finally, I agree the test is not ideally placed. I also agree with @ctrueden we could puttng Matlab utilties in a separate folder. Do you have a personal preference regarding name conventions? Should I still move the test to test/utils?

@melissalinkert
Open Microscopy Environment member

Looking much better. bfopen now just works as I'd expect.

which bfGetReader -all

gives me: /home/melissa/code/bio-formats/components/bio-formats/utils/bfGetReader.m

but bfopen(filename) does now work as expected, so it's quite likely that something was setup incorrectly before.

I added notes in the PR regarding the usage of xUnit. Should I also insert references in each TestCase instantiation?

Please do add a note in the code base somewhere, so that someone just cloning the repository can see what's going on. Even if it's just a "see PR #56 for information", that's better than nothing.

Finally, I agree the test is not ideally placed. I also agree with @ctrueden we could puttng Matlab utilties in a separate
folder. Do you have a personal preference regarding name conventions? Should I still move the test to test/utils?

I'd vote for moving the tests to components/bio-formats/test/matlab and the "proper" *.m files to components/bio-formats/matlab. I would prefer not to use the Maven convention unless we decide to adopt that completely across the project (and even then, it wouldn't make me too happy to always be typing an extra tab).

Once you have those files moved, I'm happy to merge.

@joshmoore
Open Microscopy Environment member

@sbesson, do you want to fix the merge conflict?

@melissalinkert melissalinkert merged commit e75e243 into openmicroscopy:develop Apr 26, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment