Commit 766506d7 authored by danyfel80's avatar danyfel80
Browse files

new batch operation implemented

- adapted viewer to have columns as letters and rows as numbers
- batch iterates using the following priority: first checks row, then
column
- adapted Im file reader to new data model.
- Deprecated files for old data model.
- TODO adapt ScanR format.
parent 19d4d903
......@@ -12,7 +12,7 @@
<description/>
<build>
<plugins>
<plugin>
<!--<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.3.2</version>
......@@ -27,7 +27,7 @@
<configuration>
<mainClass>icy.main.Icy</mainClass>
</configuration>
</plugin>
</plugin>-->
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-javadoc-plugin</artifactId>
......
package danyfel80.wells.data.im;
import java.awt.Color;
import java.awt.Point;
import java.io.IOException;
import java.nio.file.Path;
import javax.imageio.ImageReader;
import org.w3c.dom.Element;
import danyfel80.wells.data.IChannel;
......@@ -10,46 +17,60 @@ import danyfel80.wells.data.IChannel;
public class ImChannel implements IChannel
{
public static class Builder
{
public static ImChannel createChannel(Element gridElement, Path imagePath, Point positionInWell,
ImageReader reader, int chId) throws IOException
{
ImChannel channel = new ImChannel();
channel.id = chId;
channel.name = "" + chId;
channel.image = ImImage.Builder.createImage(gridElement, imagePath, positionInWell, reader, chId);
return channel;
}
}
private long id;
private String name;
private ImImage image;
@Override
public long getId()
{
// TODO Auto-generated method stub
return 0;
return id;
}
@Override
public String getName()
{
// TODO Auto-generated method stub
return null;
return name;
}
@Override
public Color getColor()
{
// TODO Auto-generated method stub
return null;
}
@Override
public double getExcitationWavelength()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public double getEmissionWavelength()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public ImImage getImage()
{
// TODO Auto-generated method stub
return null;
return image;
}
}
package danyfel80.wells.data.im;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.geom.Dimension2D;
import java.awt.geom.Point2D;
import java.awt.geom.Point2D.Double;
import java.awt.geom.Rectangle2D;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Element;
import danyfel80.wells.data.IField;
/**
* @author Daniel Felipe Gonzalez Obando
*
*/
public class ImField implements IField
{
public Double position;
public static class Builder
{
public static ImField createSingleField(Element gridElement, Path imagePath, Point positionInWell)
throws IOException
{
ImField field = new ImField();
field.id = 0;
field.planes = new HashMap<>();
ImPlane plane = ImPlane.Builder.createSinglePlane(gridElement, imagePath, positionInWell);
field.planes.put(plane.getId(), plane);
Dimension2D pixelResolution = new icy.type.dimension.Dimension2D.Double();
Dimension imageSize = new Dimension();
plane.getTimepoints().values().stream().findFirst()
.ifPresent(t -> t.getChannels().values().stream().findFirst().ifPresent(ch -> {
pixelResolution.setSize(ch.getImage().getResolution());
imageSize.setSize(ch.getImage().getSizeXY());
}));
field.positionInWell = new Point2D.Double();
field.bounds = new Rectangle2D.Double(0, 0, imageSize.width * pixelResolution.getWidth(),
imageSize.height * pixelResolution.getHeight());
field.pixelBounds = new Rectangle2D.Double(0, 0, imageSize.width, imageSize.height);
return field;
}
}
private long id;
private Point2D positionInWell;
private Map<Long, ImPlane> planes;
private Rectangle2D bounds;
private Rectangle2D pixelBounds;
@Override
public long getId()
{
// TODO Auto-generated method stub
return 0;
return id;
}
@Override
public Point2D getPosition()
{
// TODO Auto-generated method stub
return null;
return positionInWell;
}
@Override
public Map<Long, ImPlane> getPlanes()
{
// TODO Auto-generated method stub
return null;
return planes;
}
@Override
public Rectangle2D getBounds()
{
// TODO Auto-generated method stub
return null;
return bounds;
}
@Override
public Rectangle2D getPixelBounds()
{
// TODO Auto-generated method stub
return null;
return pixelBounds;
}
}
package danyfel80.wells.data.im;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Point;
import java.awt.geom.Dimension2D;
import java.io.IOException;
import java.nio.file.Path;
import java.util.Date;
import javax.imageio.ImageReader;
import org.w3c.dom.Element;
import danyfel80.wells.data.IImage;
import icy.util.XMLUtil;
/**
* @author Daniel Felipe Gonzalez Obando
......@@ -11,185 +21,198 @@ import danyfel80.wells.data.IImage;
public class ImImage implements IImage
{
public static class Builder
{
public static ImImage createImage(Element gridElement, Path imagePath, Point positionInWell, ImageReader reader,
int chId) throws IOException
{
ImImage image = new ImImage();
image.id = chId;
image.url = imagePath.toString();
Element xres = XMLUtil.getElement(gridElement, "XResolution");
Element yres = XMLUtil.getElement(gridElement, "YResolution");
image.resolution = new icy.type.dimension.Dimension2D.Double(
XMLUtil.getAttributeDoubleValue(xres, "Value", 1.0),
XMLUtil.getAttributeDoubleValue(yres, "Value", 1.0));
image.sizeXY = new Dimension(reader.getWidth(chId), reader.getHeight(chId));
return image;
}
}
private int id;
private String url;
private Dimension2D resolution;
private Dimension sizeXY;
@Override
public String getVersion()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getId()
{
// TODO Auto-generated method stub
return null;
return "" + id;
}
@Override
public String getState()
{
// TODO Auto-generated method stub
return null;
}
@Override
public long getBufferNumber()
{
// TODO Auto-generated method stub
return 0;
return id;
}
@Override
public String getUrl()
{
// TODO Auto-generated method stub
return null;
return url;
}
@Override
public long getRow()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getColumn()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getFieldId()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getPlaneId()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getTimepointId()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public long getChannelId()
{
// TODO Auto-generated method stub
return 0;
return id;
}
@Override
public Color getChannelColor()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getChannelType()
{
// TODO Auto-generated method stub
return null;
}
@Override
public String getAcquisitionType()
{
// TODO Auto-generated method stub
return null;
}
public Dimension2D getResolution()
{
return resolution;
}
@Override
public double getResolutionX()
{
// TODO Auto-generated method stub
return 0;
return resolution.getWidth();
}
@Override
public double getResolutionY()
{
// TODO Auto-generated method stub
return 0;
return resolution.getHeight();
}
public Dimension getSizeXY()
{
return sizeXY;
}
@Override
public long getSizeX()
{
// TODO Auto-generated method stub
return 0;
return sizeXY.width;
}
@Override
public long getSizeY()
{
// TODO Auto-generated method stub
return 0;
return sizeXY.height;
}
@Override
public double getPositionX()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public double getPositionY()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public double getAbsPositionZ()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public double getPositionZ()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public double getTime()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public Date getDate()
{
// TODO Auto-generated method stub
return null;
}
@Override
public double getExcitationWavelength()
{
// TODO Auto-generated method stub
return 0;
}
@Override
public double getEmissionWavelength()
{
// TODO Auto-generated method stub
return 0;
}
......
package danyfel80.wells.data.im;
import java.awt.Point;
import java.io.IOException;
import java.nio.file.Path;
import java.util.HashMap;
import java.util.Map;
import org.w3c.dom.Element;
import danyfel80.wells.data.IPlane;
/**
......@@ -10,25 +16,41 @@ import danyfel80.wells.data.IPlane;
public class ImPlane implements IPlane
{
public static class Builder
{
public static ImPlane createSinglePlane(Element gridElement, Path imagePath, Point positionInWell)
throws IOException
{
ImPlane plane = new ImPlane();
plane.id = 0;
plane.positionZ = 0;
plane.timepoints = new HashMap<>();
ImTimepoint timepoint = ImTimepoint.Builder.createSingleTimepoint(gridElement, imagePath, positionInWell);
plane.timepoints.put(timepoint.getId(), timepoint);
return plane;
}
}
private long id;
private double positionZ;
private Map<Long, ImTimepoint> timepoints;
@Override
public long getId()
{
// TODO Auto-generated method stub
return 0;
return id;
}
@Override
public double getPositionZ()
{
// TODO Auto-generated method stub
return 0;
return positionZ;
}
@Override
public Map<Long, ImTimepoint> getTimepoints()
{
// TODO Auto-generated method stub
return null;
return timepoints;
}
}
......@@ -2,15 +2,20 @@ package danyfel80.wells.data.im;
import java.awt.Dimension;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.function.DoubleSupplier;
import java.util.function.Function;
import java.util.function.Supplier;
import java.util.stream.Collectors;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import danyfel80.wells.data.IPlate;
import danyfel80.wells.util.MessageProgressListener;
import danyfel80.wells.util.stream.StreamUtils;
import icy.util.XMLUtil;
/**
......@@ -26,14 +31,17 @@ public class ImPlate implements IPlate
{
private String xmlFile;
private String folderPath;
private MessageProgressListener progressListener;
/**
* @param xmlFile
* @param xmlFilePath
* @param folderPath
*/
public Builder(String xmlFile)
public Builder(String xmlFilePath, String folderPath)
{
this.xmlFile = xmlFile;
this.xmlFile = xmlFilePath;
this.folderPath = folderPath;
}
public Builder progressListener(MessageProgressListener progressListener)
......@@ -46,8 +54,19 @@ public class ImPlate implements IPlate
{
notifyProgress(() -> 0.01, () -> "Loading xml descriptor file");
Document plateDescriptionDocument = loadXMLDescriptorFile();
// TODO complete this reader
return null;
Element gridElement = XMLUtil.getElement(plateDescriptionDocument, "ExperimentGrid");
Element plateSettings = XMLUtil.getElement(gridElement, "PlateSetting");
ImPlate plate = new ImPlate();
plate.id = XMLUtil.getAttributeValue(plateSettings, "GID", "unknown plate");
plate.name = plate.id;
plate.type = "Unknown";
plate.dimension = new Dimension(XMLUtil.getAttributeIntValue(plateSettings, "XWells", 0),
XMLUtil.getAttributeIntValue(plateSettings, "YWells", 0));
plate.wells = getWellsFromGridElement(plate, gridElement);
return plate;
}
private Document loadXMLDescriptorFile() throws IOException
......@@ -56,6 +75,16 @@ public class ImPlate implements IPlate
.orElseThrow(() -> new IOException("Could not read xml from file"));
}
private Map<Long, ImWell> getWellsFromGridElement(ImPlate plate, Element gridElement)
{
List<Element> wellElements = XMLUtil.getElements(gridElement, "Experiment");
Map<Long, ImWell> wells = wellElements.stream()
.map(StreamUtils.<Element, ImWell> wrapFunction(
wellElement -> ImWell.Builder.fromXMLElement(gridElement, wellElement, folderPath)))
.collect(Collectors.toMap(ImWell::getId, Function.identity()));
return wells;
}
private void notifyProgress(DoubleSupplier progress, Supplier<String> message)
{
if (progressListener != null)
......@@ -66,39 +95,40 @@ public class ImPlate implements IPlate
}