1.MATLAB 配置 Micro-Manager

Micro-Manager

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

配置官方原文:Matlab Cnfiguration

第一步:系统环境变量配置,添加 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 下

 

function [] = MMsetup_javaclasspath(path2MM)
fileList = getAllFiles(path2MM);
fileListJarBool = regexp(fileList,'.jar$','end');
fileListJarBool = cellfun(@isempty,fileListJarBool);
fileListJar = fileList(~fileListJarBool);
fid = fopen(fullfile(prefdir,'MMjavaclasspath.txt'),'w');
fprintf(fid,'<before>\r\n');
cellfun(@(x) fprintf(fid,'%s\r\n',x), fileListJar);
fclose(fid);
%% nested directory listing ala gnovice from stackoverflow
% inputs and outputs are self-explanatory
function fileList = getAllFiles(dirName)
dirData = dir(dirName);      % Get the data for the current directory
dirIndex = [dirData.isdir];  % Find the index for directories
fileList = {dirData(~dirIndex).name}';  % Get a list of the files
if ~isempty(fileList)
    fileList = cellfun(@(x) fullfile(dirName,x),fileList,'UniformOutput',false);
end
subDirs = {dirData(dirIndex).name};  % Get a list of the subdirectories
validIndex = ~ismember(subDirs,{'.','..'});  % Find index of subdirectories
%    that are not '.' or '..'
for iDir = find(validIndex)                  % Loop over valid subdirectories
    nextDir = fullfile(dirName,subDirs{iDir});    % Get the subdirectory path
    fileList = vertcat(fileList, getAllFiles(nextDir));  % Recursively call getAllFiles
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 ('E:\SoftSetUp\Micro-Manager-1.4\MMConfig_demo.cfg');E:\SoftSetUp\Micro-Manager-1.4\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
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值