• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

MATLAB 配置 Micro-Manager

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

Micro-Manager

注: Win10 配置 MATLAB 和 Miro-Manager 的联系,使得 MATLAB 可以调用 Miro-Manager 的内置函数。

第一步:系统环境变量配置,添加 Miro-Manager 安装路径 E:\SoftSetUp\Micro-Manager-1.4

第二步:在 MATLAB 命令行中敲入

>> edit([prefdir \'/javaclasspath.txt\']);

并将 Micro-Manager 安装路径下的 *.jar 文件加入到文本中。

E:\SoftSetUp\Micro-Manager-1.4\ij.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\bsh-2.0b4.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\clojure-1.3.0.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\clooj-0.2.7.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\commons-math-2.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\commons-math3-3.4.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\core.cache-0.6.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\core.memoize-0.5.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\data.json-0.1.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\formats-api-5.1.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\formats-common-5.1.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\gson-2.2.4.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\guava-17.0.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\jcommon-1.0.23.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\jfreechart-1.0.19.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\joda-time-2.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\kryo-2.24.0.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\logback-classic-1.1.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\logback-core-1.1.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\miglayout-core-4.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\miglayout-swing-4.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\minlog-1.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\MMAcqEngine.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\MMCoreJ.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\MMJ_.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\objenesis-2.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\ome-xml-5.1.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\protobuf-java-2.5.0.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\rsyntaxtextarea-2.5.2.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\serializer-2.7.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\slf4j-api-1.7.6.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\swingx-0.9.5.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\TSFProto-SVN.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\xalan-2.7.1.jar
E:\SoftSetUp\Micro-Manager-1.4\plugins\Micro-Manager\xml-apis-1.3.04.jar

第三步:在 MATLAB 中敲入

>> edit librarypath.txt 

将安装路径下的 E:\SoftSetUp\Micro-Manager-1.4\ 加入该文本。

第四步:重启 MATLAB

第五步:创建 MATLAB 函数 MMsetup_javaclasspath() ,并将之存于 javaclasspath.txt 所保存的文件夹 C:\Users\gh\AppData\Roaming\MathWorks\MATLAB\R2017b 下

 1 function [] = MMsetup_javaclasspath(path2MM)
 2 fileList = getAllFiles(path2MM);
 3 fileListJarBool = regexp(fileList,\'.jar$\',\'end\');
 4 fileListJarBool = cellfun(@isempty,fileListJarBool);
 5 fileListJar = fileList(~fileListJarBool);
 6 fid = fopen(fullfile(prefdir,\'MMjavaclasspath.txt\'),\'w\');
 7 fprintf(fid,\'<before>\r\n\');
 8 cellfun(@(x) fprintf(fid,\'%s\r\n\',x), fileListJar);
 9 fclose(fid);
10 %% nested directory listing ala gnovice from stackoverflow
11 % inputs and outputs are self-explanatory
12 function fileList = getAllFiles(dirName)
13 dirData = dir(dirName);      % Get the data for the current directory
14 dirIndex = [dirData.isdir];  % Find the index for directories
15 fileList = {dirData(~dirIndex).name}\';  % Get a list of the files
16 if ~isempty(fileList)
17     fileList = cellfun(@(x) fullfile(dirName,x),fileList,\'UniformOutput\',false);
18 end
19 subDirs = {dirData(dirIndex).name};  % Get a list of the subdirectories
20 validIndex = ~ismember(subDirs,{\'.\',\'..\'});  % Find index of subdirectories
21 %    that are not \'.\' or \'..\'
22 for iDir = find(validIndex)                  % Loop over valid subdirectories
23     nextDir = fullfile(dirName,subDirs{iDir});    % Get the subdirectory path
24     fileList = vertcat(fileList, getAllFiles(nextDir));  % Recursively call getAllFiles
25 end

其中 path2MM 为 E:\SoftSetUp\Micro-Manager-1.4\MMConfig_demo.cfg ,在运行 MATLAB 和 Micro-Manager 时先运行此程序,会在文件夹 C:\Users\gh\AppData\Roaming\MathWorks\MATLAB\R2017b 下生成一个txt文件 MMjavaclasspath.txt 。

第五步:调试并创建一个 Java 对象为类 MMCcore

>> import mmcorej.*;
>> mmc = CMMCore;
>> mmc.loadSystemConfiguration (\'<span style="color:#4f4f4f;">E:\SoftSetUp\Micro-Manager-1.4\</span>MMConfig_demo.cfg\');

其中 E:\SoftSetUp\Micro-Manager-1.4\MMConfig_demo.cfg 是显微镜和 Micro-Manager 之间的配置文件,依据不同的配置加载不同的文件。根据加载的配置文件,调试 MATLAB 是否能够正常调用内置函数

>> mmc.snapImage();%抓拍图
>> tipImage = mmc.getImage();  
>> width = mmc.getImageWidth();
>> height = mmc.getImageHeight();
>> if mmc.getBytesPerPixel == 2
        pixelType = \'uint16\';
>> else
        pixelType = \'uint8\';
>> end
>> tipImage = typecast(tipImage, pixelType);
>> tipImage = reshape(tipImage, [width, height]);
>> tipImage = transpose(tipImage);

以上程序实现的功能是将显微镜的相机抓拍的图通过变换转化为可读的图像,也可以将图像保存到电脑文件夹中

>> imwrite(tipImage,\'E;\img.tif\');

到此,调试成功!

注:如要使用 MMGUI ,则使用以下代码代替第五步中的 Java 对象的创建

>> import org.micromanager.MMStudio;
>> gui = MMStudio(false);
>> gui.show;
>> mmc = gui.getCore;
>> acq = gui.getAcquisitionEngine;

 


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
DelphiXE5forAndroid(八)发布时间:2022-07-18
下一篇:
DELPHI安卓动态权限申请发布时间:2022-07-18
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap