Compare commits

...

12 Commits

Author SHA1 Message Date
Damien Goutte-Gattat ce283aba22 [maven-release-plugin] prepare for next development iteration 2 months ago
Damien Goutte-Gattat 6c35f22a01 [maven-release-plugin] prepare release incenp-imagej-plugins-0.9.6 2 months ago
Damien Goutte-Gattat b35fd4d14b Match header names in a case-insensitive manner by default. 2 months ago
Damien Goutte-Gattat 90f35b8bac Allow several names when looking for a specific cell. 2 months ago
Damien Goutte-Gattat 8a7339a2e8 [maven-release-plugin] prepare for next development iteration 2 months ago
Damien Goutte-Gattat b4a710ebbc [maven-release-plugin] prepare release incenp-imagej-plugins-0.9.5 2 months ago
Damien Goutte-Gattat 48fe51eb13 Update documentation. 2 months ago
Damien Goutte-Gattat f8c4267e18 Add the SciJava repository. 2 months ago
Damien Goutte-Gattat 1792a18875 Always call readCSV() if needed. 2 months ago
Damien Goutte-Gattat 7527b2e42f Bump dependencies. 2 months ago
Damien Goutte-Gattat ca7fa551bc Update documentation. 9 months ago
Damien Goutte-Gattat da77c7abc1 [maven-release-plugin] prepare for next development iteration 9 months ago
  1. 8
      NEWS
  2. 6
      README.md
  3. 17
      pom.xml
  4. 74
      src/main/java/org/incenp/imagej/BatchReader.java
  5. 22
      src/site/apt/index.apt

8
NEWS

@ -1,3 +1,11 @@
Changes in incenp-imagej-plugins-0.9.5
--------------------------------------
* Remove the need to explicitly call BatchReader.readCSV().
* Explicitly refer to the SciJava Maven repository in POM.
* Require more recent ImageJ (needed for MacOS development).
Changes in incenp-imagej-plugins-0.9.4
--------------------------------------

6
README.md

@ -24,9 +24,9 @@ Bundled with the plugins is a small library of helper classes for use in
other plugins or scripts. Notable classes include `BatchReader`, to
facilitate batch processing of images listed in a CSV input file, and
`ChannelMasker`, to facilitate the creation and manipulation of
binary masks. Refer to the package´s [Javadoc]
(https://incenp.org/dvlpt/imagej-plugins/apidocs/index.html) for more
details.
binary masks. Refer to the package´s
[Javadoc](https://incenp.org/dvlpt/imagej-plugins/apidocs/index.html)
for more details.
Installation
------------

17
pom.xml

@ -3,7 +3,7 @@
<groupId>org.incenp</groupId>
<artifactId>incenp-imagej-plugins</artifactId>
<version>0.9.4</version>
<version>0.9.7-SNAPSHOT</version>
<name>Incenp.org ImageJ Plugins</name>
<description>Some plugins for ImageJ</description>
<url>https://incenp.org/dvlpt/imagej-plugins/</url>
@ -29,7 +29,7 @@
<connection>scm:git:https://git.incenp.org/damien/imagej-plugins.git</connection>
<developerConnection>scm:git:ssh://git@git.incenp.org/damien/imagej-plugins.git</developerConnection>
<url>https://git.incenp.org/damien/imagej-plugins</url>
<tag>incenp-imagej-plugins-0.9.4</tag>
<tag>HEAD</tag>
</scm>
<issueManagement>
@ -47,23 +47,30 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>
<repositories>
<repository>
<id>scijava.public</id>
<url>https://maven.scijava.org/content/groups/public</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej</artifactId>
<version>2.0.0-rc-71</version>
<version>2.2.0</version>
</dependency>
<dependency>
<groupId>net.imagej</groupId>
<artifactId>imagej-legacy</artifactId>
<version>0.36.0</version>
<version>0.37.4</version>
</dependency>
<dependency>
<!-- For ImageJ2 plugin API -->
<groupId>org.scijava</groupId>
<artifactId>scijava-common</artifactId>
<version>2.77.0</version>
<version>2.85.0</version>
</dependency>
<dependency>
<!-- For util.opencsv -->

74
src/main/java/org/incenp/imagej/BatchReader.java

@ -64,6 +64,7 @@ public class BatchReader {
private String filename;
private String[] headers;
private boolean withHeaders;
private boolean caseSensitiveHeaders;
private ArrayList<String[]> rows;
private ImagePlus[] currentImages;
private Hashtable<String, Integer> headersIndex;
@ -78,6 +79,7 @@ public class BatchReader {
public BatchReader(String filename, boolean noHeaders) {
this.filename = filename;
this.withHeaders = !noHeaders;
caseSensitiveHeaders = false;
headers = null;
headersIndex = null;
cursor = subcursor = -1;
@ -114,6 +116,19 @@ public class BatchReader {
this(file.getAbsolutePath(), noHeaders);
}
/**
* Sets the case-sensitivity option. If set to true, the
* {@link #getCell(String)} method and its overloaded variants will match header
* names in a case-sensitive way. The default is false.
*
* @param caseSensitive true to match header names case-sensitively.
*/
public void setCaseSensitive(boolean caseSensitive) {
caseSensitiveHeaders = caseSensitive;
if ( headersIndex != null )
headersIndex = null;
}
/**
* Moves to the next available image. Once this method has been called and if it
* returned true, the image can be obtained by calling the {@link #getImage()}
@ -214,29 +229,62 @@ public class BatchReader {
}
/**
* Gets the contents of a specific cell within the current row.
* Gets the contents of a specific cell within the current row. The cell is
* searched for using several equally accepted names.
*
* @param name the column name, as indicated in the header row
* @param names an array of accepted column names
* @param fallback the default value to return if the cell is not found
* @return the contents of the specified cell
*/
public String getCell(String name) {
public String getCell(String[] names, String fallback) {
if ( headersIndex == null ) {
if ( (headersIndex = getHeadersIndex()) == null )
return null;
}
Integer indexObject = headersIndex.get(name);
if ( indexObject == null )
return "";
Integer index = null;
for ( int i = 0; i < names.length && index == null; i++ ) {
if ( !caseSensitiveHeaders )
index = headersIndex.get(names[i].toLowerCase());
else
index = headersIndex.get(names[i]);
}
return getCell(indexObject.intValue());
if ( index == null )
return fallback;
return getCell(index.intValue());
}
/**
* Gets the contents of a specific cell within the current row. The cell is
* searched for using several equally accepted names.
*
* @param names an array of accepted column names
* @return the contents of the specified cell
*/
public String getCell(String[] names) {
return getCell(names, "");
}
/**
* Gets the contents of a specific cell within the current row.
*
* @param name the column name, as indicated in the header row
* @return the contents of the specified cell
*/
public String getCell(String name) {
return getCell(new String[] { name }, "");
}
private Hashtable<String, Integer> getHeadersIndex() {
if ( headersIndex == null && headers != null ) {
headersIndex = new Hashtable<String, Integer>();
for ( int i = 0; i < headers.length; i++ ) {
headersIndex.put(headers[i], i);
if ( !caseSensitiveHeaders )
headersIndex.put(headers[i].toLowerCase(), i);
else
headersIndex.put(headers[i], i);
}
}
@ -281,7 +329,11 @@ public class BatchReader {
*
* @return the CSV file headers
*/
public String[] getHeaders() {
public String[] getHeaders() throws IOException {
if ( rows == null ) {
this.readCSV();
}
if ( headers == null ) {
headers = new String[1];
headers[0] = "Image";
@ -326,9 +378,7 @@ public class BatchReader {
/**
* Reads the entire CSV file. This method is automatically called by the
* {@link #next()} method if needed. However it is necessary to explicitly call
* it if the CSV headers need to be accessed (through the {@link #getHeaders()}
* method) prior to any call to next().
* {@link #next()} or {@link #getHeaders()} methods if needed.
*
* @throws IOException if any I/O error occurs while attempting to read the file
*/

22
src/site/apt/index.apt

@ -57,9 +57,9 @@ Setup
of the project.
Simply download the latest JAR file on that page (named
<incenp-plugins-X.X.Y.jar>, where <X.Y.X> is the latest version) and
save it anywhere under the <plugins> directory of your ImageJ
installation.
<incenp-imagej-plugins-X.X.Y.jar>, where <X.Y.X> is the latest
version) and save it anywhere under the <plugins> directory of your
ImageJ installation.
The plugins will be available upon the next restart of ImageJ under
the <Plugins\>Incenp.org> menu. You may also check the plugins were
@ -79,21 +79,13 @@ $ git clone https://git.incenp.org/damien/imagej-plugins.git
The project uses {{{https://maven.apache.org/}Maven}} as its build
system, so you need to have Maven installed with the <mvn> command
available from the shell. You will then need to install the parent
POM by running:
+-------------------------------------------------------------------
$ mvn dependency:get -DgroupId=org.incenp -DartifactId=incenp-base \
-Dversion=1.1.0 -Dpackaging=pom \
-DremoteRepositories=https://mvn.incenp.org/repo/releases
+-------------------------------------------------------------------
Then, simply run the following command from the source directory:
available from the shell. Then, simply run the following command from
the source directory:
+------------
$ mvn package
+------------
This will generate a JAR archive named <incenp-plugins-X.Y.Z.jar> in
the <target> directory. Install that file in your ImageJ’s <plugins>
This will generate a JAR archive named <incenp-imagej-plugins-X.Y.Z.jar>
in the <target> directory. Install that file in your ImageJ’s <plugins>
directory as described in the previous section.
Loading…
Cancel
Save