TrackMate issues in Mac

Tags: #<Tag:0x00007fb87d59e768> #<Tag:0x00007fb87d59e5d8> #<Tag:0x00007fb87d59e3f8> #<Tag:0x00007fb87d59e218>



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.


similar to Matlab in Win7, I am adding following path

javaaddpath ('/Users/goswamid2/Documents/Matlab/mij.jar');
addpath ('/Users/goswamid2/Documents/Matlab Scripts/bfmatlab');


Hi @debanjan.goswami

Could you copy/paste the error message please?


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



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()


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.


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.


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(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') ''];

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

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

% 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);

% 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.');
fwrite(fid, scriptContents);

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

% delete temporary file

% 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]);

Thanks again.