TrackMate issues in Mac

plugin
matlab
trackmate
fiji
Tags: #<Tag:0x00007fb87d59e768> #<Tag:0x00007fb87d59e5d8> #<Tag:0x00007fb87d59e3f8> #<Tag:0x00007fb87d59e218>

#1

@tinevez

I have been using TrackMate inside Matlab (Win7) without any problem and I import Fiji plugin classes in Matlab. Following are few lines of code as an example

import ij.*
import loci.plugins.BF.*
import java.util.HashMap
import fiji.plugin.trackmate.*
import fiji.plugin.trackmate.detection.*
import fiji.plugin.trackmate.features.*
import fiji.plugin.trackmate.features.track.*
...
...

When I use the same code in Matlab (Mac, El Capitan) the BioFormat functions are working properly, such as imp = openImagePlus(), but the TrackMate function model = Model() is showing error.

I am wondering if someone experienced a similar problem and if there is a solution for it.

I will really appreciate your help with this.

Thanks,
Debanjan

similar to Matlab in Win7, I am adding following path

javaaddpath ('/Users/goswamid2/Documents/Matlab/mij.jar');
addpath(genpath('/Applications/Fiji.app/scripts'));
addpath ('/Users/goswamid2/Documents/Matlab Scripts/bfmatlab');
clear;
Miji(false);

#2

Hi @debanjan.goswami

Could you copy/paste the error message please?


#3

Hi @tinevez,
Thank you for the response. I’m attaching screenshot below, in case I miss something

Debanjan


#4

I do not have MATLAB with me but could you try to just specify the full class path when calling model? That is, use:
model = fiji.plugin.trackmate.Model()
best
jy


#5

I suspected that and tried it before. It showed similar error as follows:

Undefined variable "fiji" or class "fiji.plugin.trackmate.Model".

Error in TrackMate_MatlabScript (line 63)
model = fiji.plugin.trackmate.Model();

Thanks for your quick response.


#6

Hi @debanjan.goswami

I had the same problem and noticed it was linked to the Java version you use in MATLAB.
You must have java 8 to use Fiji stuff in MATLAB. Check that the JVM you have in MATLAB is java 8.


#7

thanks jy @tinevez … Your suggestion hit the nail straight. I really appreciate your help on this.

I’d like to mention that getting the correct java version linked to Matlab (Mac 64 bit) is little bit of a hassle. I found the following little piece of info at Mathworks website helped me in case if anyone run on to similar issue. I am attaching the script that easily solved linking the new java path to Matlab and created a shortcut for convenience at the Desktop. If someone needs it.

function createMATLABShortcut(jvmpath)
%CREATEMATLABSHORTCUT
%   CREATEMATLABSHORTCUT(JVMPATH) creates a shortcut to start MATLAB on the
%   Desktop with a changed JVM path. If the input argument JVMPATH is
%   given, that path is used in the generated script. If JVMPATH is not
%   given a default path of:
%   /Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home
%   will be used.
%   This path is the location where Oracle's Java 7 is installed by default.
%

outputFilename = ['~/Desktop/MATLAB_R' version('-release') '_JVMstarter.app'];

if exist(outputFilename, 'file')
    error('createMATLABShortcut:targetExists', ['Destination file already exists, please (re)move file: ' outputFilename]);
end

if nargin < 1
    jvmpath = '/Library/Internet Plug-Ins/JavaAppletPlugin.plugin/Contents/Home';
end

% verify if jvmpath contains a 'bin' and a 'lib' directory
bindir = fullfile(jvmpath, 'bin');
libdir = fullfile(jvmpath, 'lib');

if ~exist(bindir, 'dir') || ~exist(libdir, 'dir')
    msg = ['Could not find a ''dir'' and ''lib'' directory in %s. Please verify that\n' ...
           'a Java JRE is installed.'];
    error('createMATLABShortcut:jvmpathInvalid', msg, jvmpath);
end

% create Applescript
shellcmd = ['/bin/bash -c ''export MATLAB_JAVA=\"' jvmpath '\"; open ' matlabroot ''''];
scriptContents = ['do shell script "' shellcmd '"'];
fid = fopen('startMATLAB.scpt', 'w');
if fid == -1
    error('createMATLABShortcut:fopenFailed', 'Could not open temporary file startMATLAB.scpt for writing.');
end
fwrite(fid, scriptContents);
fclose(fid);

% create .app to start MATLAB
system(['osacompile -o ' outputFilename ' -x startMATLAB.scpt']);

% delete temporary file
delete('startMATLAB.scpt');

% copy MATLAB icon from MATLAB to startup script and select it
copyfile(fullfile(matlabroot, 'Contents', 'Resources', 'MATLAB.icns'), fullfile(outputFilename, 'Contents', 'Resources', 'MATLAB.icns'))
system(['defaults write ' fullfile(outputFilename, 'Contents', 'Info') ' CFBundleIconFile MATLAB']);
% refresh icon for shortcut
system(['touch ' outputFilename]);

https://www.mathworks.com/matlabcentral/answers/103056-how-do-i-change-the-java-virtual-machine-jvm-that-matlab-is-using-for-mac-os

Thanks again.

Cheers,
Debanjan