-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* 3D networks can now run 2D images * check for fixed dimension sizes (like channel dim 2 for IsoNet) * introducing InputValidator, this still has to be improved
- Loading branch information
1 parent
5012d68
commit 1aec0d6
Showing
9 changed files
with
145 additions
and
73 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
39 changes: 39 additions & 0 deletions
39
src/main/java/org/csbdeep/network/DefaultInputValidator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
|
||
package org.csbdeep.network; | ||
|
||
import java.util.*; | ||
|
||
import net.imagej.axis.AxisType; | ||
import net.imglib2.exception.IncompatibleTypeException; | ||
import org.csbdeep.network.model.Network; | ||
import org.csbdeep.task.DefaultTask; | ||
|
||
import net.imagej.Dataset; | ||
import net.imagej.axis.Axes; | ||
|
||
public class DefaultInputValidator extends DefaultTask implements InputValidator { | ||
|
||
@Override | ||
public void run(final Dataset input, final Network network) throws IncompatibleTypeException { | ||
|
||
setStarted(); | ||
|
||
for (int i = 0; i < network.getInputNode().getNodeShape().length; i++) { | ||
AxisType axis = network.getInputNode().getNodeAxis(i); | ||
long size = network.getInputNode().getNodeShape()[i]; | ||
if(size > 1) { | ||
if(!input.axis(axis).isPresent()) { | ||
throw new IncompatibleTypeException(input, "Input should have axis of type " + axis.getLabel()); | ||
} | ||
if(input.dimension(axis) != size) { | ||
throw new IncompatibleTypeException(input, "Input axis of type " + axis.getLabel() + " should have size " + size); | ||
} | ||
} | ||
} | ||
|
||
setFinished(); | ||
|
||
} | ||
|
||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
|
||
package org.csbdeep.network; | ||
|
||
import net.imglib2.exception.IncompatibleTypeException; | ||
import org.csbdeep.network.model.Network; | ||
import org.csbdeep.task.Task; | ||
|
||
import net.imagej.Dataset; | ||
|
||
public interface InputValidator extends Task { | ||
|
||
void run(Dataset input, Network network) throws IncompatibleTypeException; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 45 additions & 25 deletions
70
src/test/java/org/csbdeep/commands/GenericIsotropicNetworkTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters