Skip to content

Commit

Permalink
Merge pull request #197 from mianalysis/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
sjcross authored Aug 23, 2024
2 parents 8ce2f33 + 402dca2 commit d9eb469
Show file tree
Hide file tree
Showing 56 changed files with 2,133 additions and 919 deletions.
4 changes: 2 additions & 2 deletions mia-algorithms/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<groupId>io.github.mianalysis</groupId>
<artifactId>pom-mia</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
</parent>

<groupId>io.github.mianalysis</groupId>
<artifactId>mia-algorithms</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
<packaging>jar</packaging>
<name>mia-algorithms</name>
<url>https://github.com/mianalysis/mia</url>
Expand Down
4 changes: 2 additions & 2 deletions mia-bonej/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<groupId>io.github.mianalysis</groupId>
<artifactId>pom-mia</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
</parent>

<groupId>io.github.mianalysis</groupId>
<artifactId>mia-bonej</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
<packaging>jar</packaging>
<name>mia-bonej</name>
<url>https://github.com/mianalysis/mia</url>
Expand Down
4 changes: 2 additions & 2 deletions mia-coordinates/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<groupId>io.github.mianalysis</groupId>
<artifactId>pom-mia</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
</parent>

<groupId>io.github.mianalysis</groupId>
<artifactId>mia-coordinates</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
<packaging>jar</packaging>
<name>mia-coordinates</name>
<url>https://github.com/mianalysis/mia</url>
Expand Down
4 changes: 2 additions & 2 deletions mia-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@
<parent>
<groupId>io.github.mianalysis</groupId>
<artifactId>pom-mia</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
</parent>

<groupId>io.github.mianalysis</groupId>
<artifactId>mia-core</artifactId>
<version>1.6.3</version>
<version>1.6.4</version>
<packaging>jar</packaging>
<name>mia-core</name>
<url>https://github.com/mianalysis/mia</url>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,15 +221,15 @@ public PartnerRefs updateAndGetPartnerRefs() {

switch ((String) parameters.getValue(FILTER_MODE, workspace)) {
case FilterModes.MOVE_FILTERED:
String inputObjectsName = parameters.getValue(INPUT_OBJECTS, workspace);
String outputObjectsName = parameters.getValue(OUTPUT_FILTERED_OBJECTS, workspace);

// Getting references up to this location
PartnerRefs currentRefs = modules.getPartnerRefs(this);

// Adding relationships
String[] partnerNames = currentRefs.getPartnerNamesArray(inputObjectsName);
String[] partnerNames = currentRefs.getPartnerNamesArray(outputObjectsName);
for (String partnerName : partnerNames)
returnedRefs.add(partnerRefs.getOrPut(inputObjectsName, partnerName));
returnedRefs.add(partnerRefs.getOrPut(outputObjectsName, partnerName));

break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public interface TestModes {

public boolean testDoRedirect(Workspace workspace) {
String testMode = parameters.getValue(TEST_MODE,workspace);
Module testModule = parameters.getValue(TEST_MODULE,workspace);
Module testModule = modules.getModuleByID(parameters.getValue(TEST_MODULE,workspace));

if (testModule == null)
return false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public Measurement(String name, double value) {
this.value = value;
}

public Measurement duplicate() {
return new Measurement(getName(), getValue());
}


// GETTERS AND SETTERS

Expand Down
43 changes: 42 additions & 1 deletion mia-core/src/main/java/io/github/mianalysis/mia/object/Obj.java
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,7 @@ public Obj getParent(String name) {
// If the first parent was the only one listed, returning this
if (elements.length == 1)
return parent;

// If there are additional parents listed, re-constructing the string and
// running this method on the parent
StringBuilder stringBuilder = new StringBuilder();
Expand Down Expand Up @@ -622,6 +622,47 @@ public void clearAllCoordinates() {
rois = new HashMap<>();
}

public Obj duplicate(Objs newCollection, boolean duplicateRelationships, boolean duplicateMeasurement,
boolean duplicateMetadata) {
Obj newObj = new Obj(newCollection, getID(), this);

// Duplicating coordinates
newObj.setCoordinateSet(getCoordinateSet().duplicate());

// Duplicating relationships
if (duplicateRelationships) {
for (Obj parent : parents.values()) {
newObj.addParent(parent);
parent.addChild(this);
}

for (Objs currChildren : children.values())
for (Obj child : currChildren.values()) {
newObj.addChild(child);
child.addParent(newObj);
}

for (Objs currPartners : partners.values())
for (Obj partner : currPartners.values()) {
newObj.addPartner(partner);
partner.addPartner(newObj);
}
}

// Duplicating measurements
if (duplicateMeasurement)
for (Measurement measurement : measurements.values())
newObj.addMeasurement(measurement.duplicate());

// Duplicating metadata
if (duplicateMetadata)
for (ObjMetadata metadataItem : metadata.values())
newObj.addMetadataItem(metadataItem.duplicate());

return newObj;

}

@Override
public int hashCode() {
// Updating the hash for time-point. Measurements and relationships aren't
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ public ObjMetadata(String name, String value) {
this.value = value;
}

public ObjMetadata duplicate() {
return new ObjMetadata(getName(), getValue());
}


// GETTERS AND SETTERS

Expand Down
80 changes: 63 additions & 17 deletions mia-core/src/main/java/io/github/mianalysis/mia/object/Objs.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.github.mianalysis.mia.object;

import java.awt.Color;
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.LinkedHashSet;
Expand All @@ -9,6 +10,7 @@
import ij.ImagePlus;
import ij.measure.Calibration;
import ij.measure.ResultsTable;
import ij.process.LUT;
import io.github.mianalysis.mia.module.Module;
import io.github.mianalysis.mia.module.Modules;
import io.github.mianalysis.mia.object.coordinates.Point;
Expand Down Expand Up @@ -40,7 +42,8 @@ public class Objs extends LinkedHashMap<Integer, Obj> {
private double frameInterval;
private Unit<Time> temporalUnit;

public Objs(String name, double dppXY, double dppZ, String units, int width, int height, int nSlices, int nFrames, double frameInterval, Unit<Time> temporalUnit) {
public Objs(String name, double dppXY, double dppZ, String units, int width, int height, int nSlices, int nFrames,
double frameInterval, Unit<Time> temporalUnit) {
this.name = name;
this.spatCal = new SpatCal(dppXY, dppZ, units, width, height, nSlices);
this.nFrames = nFrames;
Expand Down Expand Up @@ -208,7 +211,7 @@ public int getLargestID() {
for (Obj obj : values())
if (obj.getID() > largestID)
largestID = obj.getID();

return largestID;

}
Expand All @@ -227,7 +230,8 @@ public Obj getAsSingleObject() {
try {
newObj.add(point.duplicate());
} catch (PointOutOfRangeException e) {
// This shouldn't occur, as the points are from a collection with the same dimensions
// This shouldn't occur, as the points are from a collection with the same
// dimensions
e.printStackTrace();
}

Expand All @@ -239,7 +243,8 @@ public Image convertToImage(String outputName, HashMap<Integer, Float> hues, int
return convertToImage(outputName, hues, bitDepth, nanBackground, false);
}

public Image convertToImage(String outputName, HashMap<Integer, Float> hues, int bitDepth, boolean nanBackground, boolean verbose) {
public Image convertToImage(String outputName, HashMap<Integer, Float> hues, int bitDepth, boolean nanBackground,
boolean verbose) {
// Create output image
Image image = createImage(outputName, bitDepth);

Expand All @@ -251,8 +256,9 @@ public Image convertToImage(String outputName, HashMap<Integer, Float> hues, int
int count = 0;
for (Obj object : values()) {
object.addToImage(image, hues.get(object.getID()));
Module.writeProgressStatus(++count, size(), "objects", "Object collection");
}
if (verbose)
Module.writeProgressStatus(++count, size(), "objects", "Object collection");
}

// Assigning the spatial cal from the cal
spatCal.setImageCalibration(image.getImagePlus());
Expand All @@ -279,8 +285,26 @@ public Image convertToImageRandomColours() {

}

public Image convertToImageBinary() {
HashMap<Integer, Float> hues = ColourFactory.getSingleColourValues(this, ColourFactory.SingleColours.WHITE);
Image dispImage = convertToImage(name, hues, 8, false);

if (dispImage == null)
return null;
if (dispImage.getImagePlus() == null)
return null;

ImagePlus dispIpl = dispImage.getImagePlus();
dispIpl.setLut(LUT.createLutFromColor(Color.WHITE));
dispIpl.setPosition(1, 1, 1);
dispIpl.updateChannelAndDraw();

return dispImage;

}

public Image convertToImageIDColours() {
HashMap<Integer, Float> hues = ColourFactory.getIDHues(this,false);
HashMap<Integer, Float> hues = ColourFactory.getIDHues(this, false);
Image dispImage = convertToImage(name, hues, 32, false);

if (dispImage == null)
Expand All @@ -289,7 +313,7 @@ public Image convertToImageIDColours() {
return null;

ImagePlus dispIpl = dispImage.getImagePlus();
dispIpl.setLut(LUTs.Random(true,false));
dispIpl.setLut(LUTs.Random(true, false));
dispIpl.setPosition(1, 1, 1);
dispIpl.updateChannelAndDraw();

Expand Down Expand Up @@ -369,7 +393,7 @@ public Obj getByEqualsIgnoreNameAndID(Obj referenceObj) {
for (Obj testObj : values())
if (testObj.equalsIgnoreNameAndID(referenceObj))
return testObj;

return null;

}
Expand All @@ -381,7 +405,8 @@ public void resetCollection() {

/**
* Displays measurement values from a specific Module
* @param module The module for which measurements will be displayed
*
* @param module The module for which measurements will be displayed
* @param modules The collection of modules in which this module resides
*/
public void showMeasurements(Module module, Modules modules) {
Expand Down Expand Up @@ -471,7 +496,8 @@ public void showAllMeasurements() {

/**
* Displays metadata values from a specific Module
* @param module The module for which metadata will be displayed
*
* @param module The module for which metadata will be displayed
* @param modules The collection of modules in which this module resides
*/
public void showMetadata(Module module, Modules modules) {
Expand All @@ -487,7 +513,7 @@ public void showMetadata(Module module, Modules modules) {
LinkedHashSet<String> metadataNames = new LinkedHashSet<>();
for (ObjMetadataRef metadataRef : metadataRefs.values()) {
if (metadataRef.getObjectsName().equals(name))
metadataNames.add(metadataRef.getName());
metadataNames.add(metadataRef.getName());
}

// Iterating over each measurement, adding all the values
Expand Down Expand Up @@ -642,16 +668,15 @@ public Objs getObjectsInFrame(String outputObjectsName, int frame) {
outputObjects.setNFrames(1);

// Iterating over objects, getting those in this frame
for (Obj obj:values()) {
if (obj.getT() == frame) {
for (Obj obj : values()) {
if (obj.getT() == frame) {
Obj outputObject = new Obj(outputObjects, obj.getVolumeType(), obj.getID());
outputObject.setCoordinateSet(obj.getCoordinateSet().duplicate());
outputObject.setT(0);
outputObjects.add(outputObject);
}
}


return outputObjects;

}
Expand All @@ -671,11 +696,32 @@ public Unit<Time> getTemporalUnit() {
public void setNFrames(int nFrames) {
this.nFrames = nFrames;
}

public Objs duplicate(String newObjectsName, boolean duplicateRelationships, boolean duplicateMeasurement,
boolean duplicateMetadata, boolean addOriginalDuplicateRelationship) {
Objs newObjs = new Objs(newObjectsName, this);

for (Obj obj : values()) {
Obj newObj = obj.duplicate(newObjs, duplicateRelationships, duplicateMeasurement, duplicateMetadata);

newObjs.add(newObj);

if (addOriginalDuplicateRelationship) {
newObj.addParent(obj);
obj.addChild(newObj);
}
}

newObjs.maxID = this.maxID;

return newObjs;

}
}

// clear all
// print'HelloWorld'
// if{
// 'theSkyIsGreen'
// getMeasurements
// 'theSkyIsGreen'
// getMeasurements
// }
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ public abstract class Image<T extends RealType<T> & NativeType<T>> {

public abstract ImageRenderer getRenderer();

public abstract void clear();

public abstract void setRenderer(ImageRenderer imageRenderer);

public abstract void show(String title, @Nullable LUT lut, boolean normalise, boolean composite);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -262,6 +262,11 @@ public synchronized static ImageStack getSetStack(ImagePlus inputImagePlus, int
}
}

@Override
public void clear() {
imagePlus = null;
}

@Override
public int hashCode() {
int hash = 1;
Expand Down
Loading

0 comments on commit d9eb469

Please sign in to comment.