我正在编写一个脚本,允许我使用MIJI和TrackMate插件在MATLAB中自动分析我的图像数据集。我能够成功地运行分析,但无法从java类fiji.plugin.trackmate.TrackMate中获取跟踪数据。
我使用下面的代码来运行分析;
imp = ij.ImagePlus('S:\Swinderen\Adam\B1R1 16000 Frames 405 561nm HILO.tif');
imp.show()
%----------------------------
% Create the model object now
%----------------------------
% Some of the parameters we configure below need to have
% a reference to the model at creation. So we create an
% empty model now.
model = fiji.plugin.trackmate.Model();
% Send all messages to ImageJ log window.
model.setLogger(fiji.plugin.trackmate.Logger.IJ_LOGGER)
%------------------------
% Prepare settings object
%------------------------
settings = fiji.plugin.trackmate.Settings();
settings.setFrom(imp)
% Configure detector - We use a java map
settings.detectorFactory = fiji.plugin.trackmate.detection.LogDetectorFactory();
map = java.util.HashMap();
map.put('DO_SUBPIXEL_LOCALIZATION', true);
map.put('RADIUS', 1);
map.put('TARGET_CHANNEL', 1);
map.put('THRESHOLD', 20);
map.put('DO_MEDIAN_FILTERING', true);
settings.detectorSettings = map;
% Configure tracker - We want to allow splits and fusions
settings.trackerFactory = fiji.plugin.trackmate.tracking.sparselap.SparseLAPTrackerFactory();
settings.trackerSettings = fiji.plugin.trackmate.tracking.LAPUtils.getDefaultLAPSettingsMap(); % almost good enough
settings.trackerSettings.put('LINKING_MAX_DISTANCE', 0.3);
settings.trackerSettings.put('GAP_CLOSING_MAX_DISTANCE', 0);
settings.trackerSettings.put('SPLITTING_MAX_DISTANCE', 0);
settings.trackerSettings.put('MERGING_MAX_DISTANCE', 0);
settings.trackerSettings.put('ALLOW_GAP_CLOSING', false);
settings.trackerSettings.put('ALLOW_TRACK_SPLITTING', false);
settings.trackerSettings.put('ALLOW_TRACK_MERGING', false);
% Configure track analyzers - Later on we want to filter out tracks
% based on their displacement, so we need to state that we want
% track displacement to be calculated. By default, out of the GUI,
% not features are calculated.
% The displacement feature is provided by the TrackDurationAnalyzer.
settings.addTrackAnalyzer(fiji.plugin.trackmate.features.track.TrackDurationAnalyzer())
% Configure track filters - We want to get rid of the two immobile spots at
% the bottom right of the image. Track displacement must be above 10 pixels.
filter2 = fiji.plugin.trackmate.features.FeatureFilter('NUMBER_OF_SPOTS', 10.0, true);
settings.addTrackFilter(filter2)
%-------------------
% Instantiate plugin
%-------------------
trackmate = fiji.plugin.trackmate.TrackMate(model, settings);
%--------
% Process
%--------
ok = trackmate.checkInput();
if ~ok
display(trackmate.getErrorMessage())
end
ok = trackmate.process();
if ~ok
display(trackmate.getErrorMessage())
end在检查model时,我得到以下输出,作为1x1模型
val =
Contains 998348 spots in total.
Contains 998348 filtered spots.
Contains 203076 tracks in total.
Contains 203076 filtered tracks.
Physical units:
space units: pixels
time units: frames
Spot features declared:
- QUALITY: Quality, 'Quality' (QUALITY) - double valued.
- POSITION_X: X, 'X' (POSITION) - double valued.
- POSITION_Y: Y, 'Y' (POSITION) - double valued.
- POSITION_Z: Z, 'Z' (POSITION) - double valued.
- POSITION_T: T, 'T' (TIME) - double valued.
- FRAME: Frame, 'Frame' (NONE) - integer valued.
- RADIUS: Radius, 'R' (LENGTH) - double valued.
- VISIBILITY: Visibility, 'Visibility' (NONE) - integer valued.
Edge features declared:
Track features declared:
- TRACK_DURATION: Duration of track, 'Duration' (TIME) - double valued.
- TRACK_START: Track start, 'T start' (TIME) - double valued.
- TRACK_STOP: Track stop, 'T stop' (TIME) - double valued.
- TRACK_DISPLACEMENT: Track displacement, 'Displacement' (LENGTH) - double valued.我不知道如何访问和存储双值数据,如“质量”和“位置_X”。尝试使用model.get('QUALITY')会返回一个错误;
使用get名称'QUALITY‘不是类'fiji.plugin.trackmate.Model’实例的可访问属性时出错
我很感激任何人能提供的任何指导,如果需要任何额外的信息,请告诉我。
更新:
我已经能够隔离FeatureModel,并可以通过以下操作输出TrackFeatures;
get(model,'FeatureModel')回传
val =
Spot features declared:
- QUALITY: Quality, 'Quality' (QUALITY) - double valued.
- POSITION_X: X, 'X' (POSITION) - double valued.
- POSITION_Y: Y, 'Y' (POSITION) - double valued.
- POSITION_Z: Z, 'Z' (POSITION) - double valued.
- POSITION_T: T, 'T' (TIME) - double valued.
- FRAME: Frame, 'Frame' (NONE) - integer valued.
- RADIUS: Radius, 'R' (LENGTH) - double valued.
- VISIBILITY: Visibility, 'Visibility' (NONE) - integer valued.
Edge features declared:
Track features declared:
- TRACK_DURATION: Duration of track, 'Duration' (TIME) - double valued.
- TRACK_START: Track start, 'T start' (TIME) - double valued.
- TRACK_STOP: Track stop, 'T stop' (TIME) - double valued.
- TRACK_DISPLACEMENT: Track displacement, 'Displacement' (LENGTH) - double valued.如果我通过做echo FeatureModel来实现featureModel.echo(),它只声明轨道特性,而不声明Spot功能,这正是我真正需要的。
发布于 2019-07-25 10:27:22
我也有同样的问题,通过用户emartini https://forum.image.sc/t/problem-exporting-xml-from-trackmate-in-matlab/27242/3在图像论坛上得到了解决。
您需要添加的代码
import fiji.plugin.trackmate.io.TmXmlWriter %add this ipmort
outfile=java.io.File('F:\Projects\Matlab\Test_track_july25.xml'); %%or your file name
writer = fiji.plugin.trackmate.io.TmXmlWriter(outfile);
writer.appendModel( trackmate.getModel() ) %trackmate instantiate like this before trackmate = TrackMate(model, settings)
writer.appendSettings( trackmate.getSettings() )
writer.writeToFile()https://stackoverflow.com/questions/53093544
复制相似问题