Re: Macro use within Plugin GUI
Posted by Marcel on
URL: http://imagej.273.s1.nabble.com/Macro-use-within-Plugin-GUI-tp5008933p5008962.html
Hello,
i looked into the API of the reader. The reader has several methods to extract the (hopefully) required data.
For the access i wrote a small example class which can be accessed with an example macro:
Compile this class and put it in the plugins directory (i used Eclipse and added the plugins libs and ImageJ jar to the classpath for compilation):
*********************************************
import java.io.File;
import java.io.IOException;
import com.nrims.data.Mims_Reader;
public class Read_Mims_Meta {
private static Mims_Reader mim;
private static String path;
public static String getData(){
File fi = new File(path);
try {
mim = new Mims_Reader(fi);
} catch (IOException e) {
//log the exception
}
return (mim.getName()+" "+ mim.getRaster());
}
public static void setPath(String pathMimsFile){
path = pathMimsFile;
}
}
***********************************************
Macro which calls the class (with image example from the website):
**************************************************************
run("Read Mims Meta")
call("Read_Mims_Meta.setPath","C:/Users/Data/SampleData1.im");
result=call("Read_Mims_Meta.getData");
print(result);
You can extract several informations from the class. Have a look at the API for the class Mims_Reader.
The macro can easily extended to automize the file read if you hava a bunch of images (thats why i added a macro as an example).
Maybee it is possible to access the class with the "call" method without an extra plugin. But this worked for me.
I hope this info helps.