MATLAB中的echo()不会从java类中输出所需的信息



我在MATLAB中有一个分析脚本,它使用了MIJI和一个名为TrackMate的java插件。它使用以下脚本进行初始化,并打开一个图像文件进行分析。

% add java paths and script folder
javaaddpath 'mij.jar';
javaaddpath 'ij-1.51n.jar';
addpath 'Fiji.appscripts';
Miji(false);
% Get currently selected image
% imp = ij.IJ.openImage('http://fiji.sc/samples/FakeTracks.tif')
imp = ij.ImagePlus('B1R1 16000 Frames 405 561nm HILO.tif');
imp.show()

生成一个模型和设置对象,告诉TrackMate如何分析图像。

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

当调用get(model)时,模型返回以下组件;

Class: [1×1 java.lang.Class]
FeatureModel: [1×1 fiji.plugin.trackmate.FeatureModel]
Logger: [1×1 fiji.plugin.trackmate.Logger$5]
ModelChangeListener: [1 java.util.LinkedHashSet]
SpaceUnits: 'pixels'
Spots: [1×1 fiji.plugin.trackmate.SpotCollection]
TimeUnits: 'frames'
TrackModel: [1×1 fiji.plugin.trackmate.TrackModel]

感兴趣的是FeatureModel组件,该组件包含TrackMate的分析输出。当运行featMod = get(model,'FeatureModel')时,以下内容将作为1x1 FeatureModel返回;

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.

我可以通过声明featMod.echo()将单个值输出为java字符串,但这只是告诉我featModTrack功能声明的组件的值,而不是Spot功能声明的值,这是我完成分析所需的输出。

如何从spot features声明的组件中获取值我不明白为什么它没有给我想要的输出,而是给了我其他组件。

当我尝试用featMod.echo('SpotFeatures')专门调用它时,我会收到错误消息;

没有为类"fiji.plugin.trackmate.FeatureModel"找到具有匹配签名的方法"echo".

我也遇到了同样的问题,用户emartini在图片论坛上解决了这个问题https://forum.image.sc/t/problem-exporting-xml-from-trackmate-in-matlab/27242/3

添加所需的代码

import fiji.plugin.trackmate.io.TmXmlWriter %add this import
outfile=java.io.File('F:ProjectsMatlabTest_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()

相关内容

  • 没有找到相关文章

最新更新