Skip to content

Commit

Permalink
Updated for compatibility with MIA v1.5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
sjcross committed Feb 9, 2024
1 parent 247e7e5 commit fc0ad4b
Show file tree
Hide file tree
Showing 15 changed files with 123 additions and 30 deletions.
18 changes: 15 additions & 3 deletions DevelopmentExamples/DevEx1_CustomModule/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,24 @@ The main MIA documentation can be found at https://mianalysis.github.io and the

Adding MIA as a dependency
--------------------------
MIA can be added to Maven projects using the following dependency:
MIA can be added to Maven projects using the following dependencies:
```
<dependency>
<groupId>io.github.mianalysis</groupId>
<artifactId>mia</artifactId>
<version>1.2.10</version>
<artifactId>mia-core</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>io.github.mianalysis</groupId>
<artifactId>mia-modules</artifactId>
<version>1.5.1</version>
</dependency>
<dependency>
<groupId>io.github.mianalysis</groupId>
<artifactId>mia-plugin</artifactId>
<version>1.5.1</version>
</dependency>
```

Expand Down
16 changes: 14 additions & 2 deletions DevelopmentExamples/DevEx1_CustomModule/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,20 @@

<dependency>
<groupId>io.github.mianalysis</groupId>
<artifactId>mia</artifactId>
<version>1.4.2</version>
<artifactId>mia-core</artifactId>
<version>1.5.1</version>
</dependency>

<dependency>
<groupId>io.github.mianalysis</groupId>
<artifactId>mia-modules</artifactId>
<version>1.5.1</version>
</dependency>

<dependency>
<groupId>io.github.mianalysis</groupId>
<artifactId>mia-plugin</artifactId>
<version>1.5.1</version>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
import io.github.mianalysis.mia.process.ColourFactory;
import io.github.mianalysis.mia.process.math.CumStat;
import net.imagej.ImageJ;
import net.imagej.patcher.LegacyInjector;

/**
* An example of a MIA Module.
Expand Down Expand Up @@ -115,11 +116,14 @@ public interface Measurements {
* @param args Can be left blank
*/
public static void main(String[] args) {
// The following must be called before initialising ImageJ
LegacyInjector.preinit();

// Creating a new instance of ImageJ
new ij.ImageJ();

// Launching MIA
new ImageJ().command().run("io.github.mianalysis.mia.MIA", false);
new ImageJ().command().run("io.github.mianalysis.mia.MIA_", false);

// Adding the current module to MIA's list of available modules.
AvailableModules.addModuleName(ExampleModule.class);
Expand Down Expand Up @@ -218,7 +222,7 @@ public Status process(Workspace workspace) {
// Measuring intensity for each centroid object. Iterating over each output centroid object.
for (Obj outputObject : outputObjects.values()) {
// The MeasureObjectIntensity module has a public method that allows the intensity of a single object to be measured for a specified image. This returns a cumulative statistic (CumStat) object, from which we can extract statistics about the intensities of all coordinates in the specified object. Here, the object only has a single point, so mean, min, max and sum will all have the same value.
CumStat cs = MeasureObjectIntensity.measureIntensity(outputObject, inputImage, false);
CumStat cs = MeasureObjectIntensity.measureIntensity(outputObject, inputImage, false, false);

// Creating a new "Measurement" object to store the intensity of the centroid object. As noted above, all statistics (bar the standard deviation) will have the same value, so the "mean" is used.
Measurement intensity = new Measurement(Measurements.INTENSITY, cs.getMean());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,30 +17,43 @@
import io.github.mianalysis.mia.object.refs.collections.PartnerRefs;
import io.github.mianalysis.mia.object.system.Status;
import net.imagej.ImageJ;
import net.imagej.patcher.LegacyInjector;

/**
* A template MIA module.
*/
*/
@Plugin(type = Module.class, priority = Priority.LOW, visible = true)

public class TemplateModule extends Module {
/**
* (Optional) If we wish to put our new module into a different category to the default categories, we need to create it here. Leaving it till the {@link getCategory} method is called is too late. Here, we create a new module category called "Examples" which will be in the first level of the available modules list.
* (Optional) If we wish to put our new module into a different category to the
* default categories, we need to create it here. Leaving it till the
* {@link getCategory} method is called is too late. Here, we create a new
* module category called "Examples" which will be in the first level of the
* available modules list.
*/
private static final Category category = new Category("Examples", "Modules used in examples", Categories.ROOT,
true);



/**
* (Optional) This main function allows us to launch a new copy of Image, start MIA and add the current module to MIA. These steps are only necessary when running the MIA and the new module from a main function. When run as part of distribution, the module will be automatically included in MIA.
* (Optional) This main function allows us to launch a new copy of Image, start
* MIA and add the current module to MIA. These steps are only necessary when
* running the MIA and the new module from a main function. When run as part of
* distribution, the module will be automatically included in MIA.
*
* @param args Can be left blank
*/
public static void main(String[] args) {
// The following must be called before initialising ImageJ
LegacyInjector.preinit();

// Creating a new instance of ImageJ
new ij.ImageJ();

// Launching MIA
new ImageJ().command().run("io.github.mianalysis.mia.MIA", false);
new ImageJ().command().run("io.github.mianalysis.mia.MIA_", false);

// Adding the current module to MIA's list of available modules.
AvailableModules.addModuleName(TemplateModule.class);
Expand All @@ -59,33 +72,51 @@ public TemplateModule(Modules modules) {
}

/**
* The module category within MIA in which this module will be placed. We can choose any of the default categories available in io.github.mianalysis.mia.module.Categories or use one created along with this module. This template uses the "Example" category created at the top of this class.
* The module category within MIA in which this module will be placed. We can
* choose any of the default categories available in
* io.github.mianalysis.mia.module.Categories or use one created along with this
* module. This template uses the "Example" category created at the top of this
* class.
*/
@Override
public Category getCategory() {
return category;
}

/**
* Since MIA v1.4.0, each Module has been given a version number returned by this function. The intention is that these version numbers follow the standard semantic versioning format, where the numbers indicate changes in the form major.minor.patch. When loading a workflow, MIA checks the version number of a module against the version number of the module used to create the workflow. Based on any differences in version number, MIA will display a warning to users about the likelihood of results coming from that module being different.
* Since MIA v1.4.0, each Module has been given a version number returned by
* this function. The intention is that these version numbers follow the
* standard semantic versioning format, where the numbers indicate changes in
* the form major.minor.patch. When loading a workflow, MIA checks the version
* number of a module against the version number of the module used to create
* the workflow. Based on any differences in version number, MIA will display a
* warning to users about the likelihood of results coming from that module
* being different.
*/
@Override
public String getVersionNumber() {
return "1.0.0";
}

/**
* Each module should include a description which will be included in the GUI (accessible by going to View / Show help panel) as well as in the automatically-generated online documentation at https://mianalysis.github.io/modules.
* Each module should include a description which will be included in the GUI
* (accessible by going to View / Show help panel) as well as in the
* automatically-generated online documentation at
* https://mianalysis.github.io/modules.
*/
@Override
public String getDescription() {
return "";
}

/**
* The method which is run as part of a workflow. This method contains all the code for loading items from the MIA workspace, performing the action of this module and exporting any new items to the workspace.
* The method which is run as part of a workflow. This method contains all the
* code for loading items from the MIA workspace, performing the action of this
* module and exporting any new items to the workspace.
*
* @param workspace The current workspace containing all available images and objects (i.e. those previously output by earlier modules in the workflow).
* @param workspace The current workspace containing all available images and
* objects (i.e. those previously output by earlier modules in
* the workflow).
*/
@Override
public Status process(Workspace workspace) {
Expand All @@ -94,15 +125,21 @@ public Status process(Workspace workspace) {
}

/**
* Creates an instance of each parameter, each of which is stored in the "parameters" variable of the module. Each new instance of the module will have a new set of parameters. This method runs once, when the module is first created.
* Creates an instance of each parameter, each of which is stored in the
* "parameters" variable of the module. Each new instance of the module will
* have a new set of parameters. This method runs once, when the module is first
* created.
*/
@Override
protected void initialiseParameters() {

}

/**
* Returns the currently-active parameters for this module. The returned parameters will change depending on what other parameters are set to. The output of this module determines the parameters that are displayed in the GUI.
* Returns the currently-active parameters for this module. The returned
* parameters will change depending on what other parameters are set to. The
* output of this module determines the parameters that are displayed in the
* GUI.
*/
@Override
public Parameters updateAndGetParameters() {
Expand All @@ -111,32 +148,53 @@ public Parameters updateAndGetParameters() {
}

/**
* Measurements added to any images by this module are reported by adding their reference to an ImageMeasurementRefs collection. When no measurements are added by this module, this method can simply return "null". These references tell downstream modules what measurements are available for each image. Returned references should be the original copies stored in the local "imageMeasurementRefs" object.
* Measurements added to any images by this module are reported by adding their
* reference to an ImageMeasurementRefs collection. When no measurements are
* added by this module, this method can simply return "null". These references
* tell downstream modules what measurements are available for each image.
* Returned references should be the original copies stored in the local
* "imageMeasurementRefs" object.
*/
@Override
public ImageMeasurementRefs updateAndGetImageMeasurementRefs() {
return null;
}

/**
* Measurements added to any objects by this module are reported by adding their reference to an ObjMeasurementRefs collection. When no measurements are added by this module, this method can simply return "null". These references tell downstream modules what measurements are available for each object of a specific object collection. Returned references should be the original copies stored in the local "objectMeasurementRefs" object.
* Measurements added to any objects by this module are reported by adding their
* reference to an ObjMeasurementRefs collection. When no measurements are added
* by this module, this method can simply return "null". These references tell
* downstream modules what measurements are available for each object of a
* specific object collection. Returned references should be the original copies
* stored in the local "objectMeasurementRefs" object.
*/
@Override
public ObjMeasurementRefs updateAndGetObjectMeasurementRefs() {
return null;
return null;

}

/**
* Values added to the workspace's metadata collection by this module are reported by adding their reference to a MetadataRefs collection. When no metadata values are added by this module, this method can simply return "null". Metadata values are single values within a workspace that specify information such as the root filename or series number. These references tell downstream modules what metadata is available. Returned references should be the original copies stored in the local "metadataRefs" object.
* Values added to the workspace's metadata collection by this module are
* reported by adding their reference to a MetadataRefs collection. When no
* metadata values are added by this module, this method can simply return
* "null". Metadata values are single values within a workspace that specify
* information such as the root filename or series number. These references tell
* downstream modules what metadata is available. Returned references should be
* the original copies stored in the local "metadataRefs" object.
*/
@Override
public MetadataRefs updateAndGetMetadataReferences() {
return null;
}

/**
* Any parent-child relationships established between objects by this module are reported by adding their reference to a ParentChildRefs collection. When no parent-child relationships are added by this module, this method can simply return "null". These references tell downstream modules what parent-child relationships are available. Returned references should be the original copies stored in the local "parentChildRefs" object.
* Any parent-child relationships established between objects by this module are
* reported by adding their reference to a ParentChildRefs collection. When no
* parent-child relationships are added by this module, this method can simply
* return "null". These references tell downstream modules what parent-child
* relationships are available. Returned references should be the original
* copies stored in the local "parentChildRefs" object.
*/
@Override
public ParentChildRefs updateAndGetParentChildRefs() {
Expand All @@ -145,15 +203,22 @@ public ParentChildRefs updateAndGetParentChildRefs() {
}

/**
* Any partner-partner relationships established between objects by this module are reported by adding their reference to a PartnerRefs collection. When no partner-partner relationships are added by this module, this method can simply return "null". These references tell downstream modules what partner-partner relationships are available. Returned references should be the original copies stored in the local "partnerRefs" object.
*/
* Any partner-partner relationships established between objects by this module
* are reported by adding their reference to a PartnerRefs collection. When no
* partner-partner relationships are added by this module, this method can
* simply return "null". These references tell downstream modules what
* partner-partner relationships are available. Returned references should be
* the original copies stored in the local "partnerRefs" object.
*/
@Override
public PartnerRefs updateAndGetPartnerRefs() {
return null;
}

/**
* Can be used to perform checks on parameters or other conditions to ensure the module is configured correctly. This runs whenever a workflow is updated (e.g. a parameter in any module is changed).
* Can be used to perform checks on parameters or other conditions to ensure the
* module is configured correctly. This runs whenever a workflow is updated
* (e.g. a parameter in any module is changed).
*/
@Override
public boolean verify() {
Expand Down
2 changes: 1 addition & 1 deletion Ex1_NucleiSegmentation/Ex1_NucleiSegmentation.mia

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file modified Ex1_NucleiSegmentation/ExampleResults/Ex1_NucleiSegmentation.xlsx
Binary file not shown.
2 changes: 1 addition & 1 deletion Ex2_ObjectTracking/Ex2_ObjectTracking.mia

Large diffs are not rendered by default.

Binary file modified Ex2_ObjectTracking/ExampleResults/Ex2_Cell-Image-Library-11813.xlsx
Binary file not shown.
Binary file not shown.
Binary file not shown.
2 changes: 1 addition & 1 deletion Ex3_Skeletonisation/Ex3_Skeletonisation.mia

Large diffs are not rendered by default.

Binary file modified Ex3_Skeletonisation/ExampleResults/Ex3_Skeletonisation.xlsx
Binary file not shown.
Binary file not shown.

0 comments on commit fc0ad4b

Please sign in to comment.