Skip to content

Commit

Permalink
update MFOV tools so that they work with wafer 60/61 tile IDs
Browse files Browse the repository at this point in the history
  • Loading branch information
trautmane committed Nov 16, 2024
1 parent 08acf12 commit 0231dff
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*
* identifies tile pairs:
* ...
* groupId "1247.0", p "001_000006_019_20220407_115555.1247.0" and q "001_000006_037_20220407_115555.1247.0"
* groupId "1248.0", p "001_000006_019_20220407_172027.1248.0" and q "001_000006_037_20220407_172027.1248.0"
* groupId "1249.0", p "001_000006_019_20220407_224819.1249.0" and q "001_000006_037_20220407_224819.1249.0"
* groupId "1.0", p "w60_magc0399_scan004_m0013_s001" and q "w60_magc0399_scan004_m0013_s002"
* groupId "2.0", p "w60_magc0399_scan005_m0013_s001" and q "w60_magc0399_scan005_m0013_s002"
* groupId "3.0", p "w60_magc0399_scan006_m0013_s001" and q "w60_magc0399_scan006_m0013_s002"
* ...
* </pre>
*
Expand All @@ -33,13 +33,13 @@ public MFOVPositionPair(final OrderedCanvasIdPair pair)

/**
* Converts canvasId based upon section and tile to multi-field-of-view position id based upon slab and mfov_sfov
* (e.g. "1247.0", "001_000006_019_20220407_115555.1247.0" to "001", "000006_019").
* (e.g. "2.0", "w60_magc0399_scan005_m0013_s001" to "magc0399", "m0013_s001").
*
* @return multi-field-of-view position id derived from specified canvasId.
*/
public static CanvasId toPositionCanvasId(final CanvasId canvasId) {
return new CanvasId(canvasId.getId().substring(0, 3), // slab id
canvasId.getId().substring(5, 14)); // <mfov>_<sfov>
return new CanvasId(canvasId.getId().substring(4, 12), // slab id: magc0399
canvasId.getId().substring(21)); // <mfov>_<sfov>: m0013_s001
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -36,33 +36,40 @@
public class Utilities {

/**
* @return 001_000006 for 001_000006_019_20220407_115555.1247.0
* @return 0399_m0013 for w60_magc0399_scan005_m0013_s001
*/
public static String getMFOVForTileId(final String tileId) throws IllegalArgumentException {
if (tileId.length() < 10) {
final int magcIndex = tileId.indexOf("magc");
if ((magcIndex < 0) || (tileId.length() < (magcIndex + 18))) {
throw new IllegalArgumentException("MFOV identifier cannot be derived from tileId " + tileId);
}
return tileId.substring(0, 10);
final String magcName = tileId.substring((magcIndex + 4), (magcIndex + 8)); // 0399
final String mfovName = tileId.substring((magcIndex + 16), (magcIndex + 22)); // _m0013
return magcName + mfovName;
}

/**
* @return 001_000006_019 for 001_000006_019_20220407_115555.1247.0
* @return 0399_m0013_s001 for w60_magc0399_scan005_m0013_s001
*/
public static String getSFOVForTileId(final String tileId) throws IllegalArgumentException {
if (tileId.length() < 14) {
final int magcIndex = tileId.indexOf("magc");
if ((magcIndex < 0) || (tileId.length() < (magcIndex + 27))) {
throw new IllegalArgumentException("SFOV identifier cannot be derived from tileId " + tileId);
}
return tileId.substring(0, 14);
final String magcName = tileId.substring((magcIndex + 4), (magcIndex + 8)); // 0399
final String mfovSfovName = tileId.substring((magcIndex + 16), (magcIndex + 27)); // _m0013_s001
return magcName + mfovSfovName;
}

/**
* @return 019 for 001_000006_019_20220407_115555.1247.0
* @return 001 for w60_magc0399_scan005_m0013_s001
*/
public static String getSFOVIndexForTileId(final String tileId) throws IllegalArgumentException {
if (tileId.length() < 14) {
final int scanIndex = tileId.indexOf("scan");
if ((scanIndex < 0) || (tileId.length() < (scanIndex + 18))) {
throw new IllegalArgumentException("SFOV index cannot be derived from tileId " + tileId);
}
return tileId.substring(11, 14);
return tileId.substring(scanIndex + 15);
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void validateAndSetupDerivedValues()
qTileIdPrefixForRun = getTileIdPrefixForRun(qTileId);
pTileIdPrefixForRun = multiFieldOfViewId;
} else if ((multiFieldOfViewId == null) || (multiFieldOfViewId.length() != 10)) {
throw new IllegalArgumentException("--mfov should be a 10 character value (e.g. 001_000006)");
throw new IllegalArgumentException("--mfov should be a 10 character value (e.g. 0399_m0013)");
} else {
pTileIdPrefixForRun = multiFieldOfViewId;
qTileIdPrefixForRun = multiFieldOfViewId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,18 +18,18 @@ public void testParameterParsing() throws Exception {
public static void main(final String[] args) {

final String[] effectiveArgs = (args != null) && (args.length > 0) ? args : new String[] {
"--baseDataUrl", "http://renderer-dev.int.janelia.org:8080/render-ws/v1",
"--owner", "hess_wafer_53",
"--project", "cut_000_to_009",
"--stack", "c001_s145_v01",
"--baseDataUrl", "http://10.40.3.113:8080/render-ws/v1",
"--owner", "trautmane",
"--project", "w60_serial_290_to_299",
"--stack", "w60_s296_r00_d00",
"--xyNeighborFactor", "0.6", // for tiles completely within mFov
"--sameLayerDerivedMatchWeight", "0.15",
"--crossLayerDerivedMatchWeight", "0.1",
// "--pTileId", "145_000010_001_20220618_040953.80.0",
// "--qTileId", "145_000010_002_20220618_040953.80.0",

"--matchCollection", "c001_s145_v01_match",
"--matchStorageCollection", "c001_s145_v01_match_try3",
"--matchCollection", "w60_s296_r00_d00_match",
"--matchStorageCollection", "w60_s296_r00_d00_match_test",


//"--mfov", "001_000003",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
package org.janelia.render.client.multisem;

import org.janelia.alignment.match.CanvasId;
import org.janelia.alignment.match.MontageRelativePosition;
import org.junit.Assert;
import org.junit.Test;

/**
* Tests the {@link MFOVPositionPair} class.
*
* @author Eric Trautman
*/
public class MFOVPositionPairTest {

@Test
public void testToPositionCanvasId() {
final CanvasId tilePairId = new CanvasId("1.0",
"w60_magc0399_scan004_m0013_s001",
MontageRelativePosition.LEFT);
final CanvasId positionPairId = MFOVPositionPair.toPositionCanvasId(tilePairId);
Assert.assertEquals("invalid canvas group id", "magc0399", positionPairId.getGroupId());
Assert.assertEquals("invalid canvas id", "m0013_s001", positionPairId.getId());
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ public void testParameterParsing() throws Exception {
public static void main(final String[] args) {

final String[] effectiveArgs = (args != null) && (args.length > 0) ? args : new String[] {
"--baseDataUrl", "http://renderer-dev.int.janelia.org:8080/render-ws/v1",
"--owner", "hess_wafer_53",
"--project", "cut_000_to_009",
"--stack", "c001_s145_v01",
"--minPairsForConnection", "6",
"--unconnectedMFOVPairsDirectory", "/Users/trautmane/Desktop/mfov",
"--baseDataUrl", "http://10.40.3.113:8080/render-ws/v1",
"--owner", "trautmane",
"--project", "w60_serial_290_to_299",
"--stack", "w60_s296_r00_d00",
"--minPairsForConnection", "2",
"--unconnectedMFOVPairsDirectory", "/Users/trautmane/Desktop/mfov_2",
"--montageStackSuffix", "_mfov_montage"
};

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package org.janelia.render.client.multisem;

import org.junit.Assert;
import org.junit.Test;

/**
* Tests the {@link Utilities} class.
*
* @author Eric Trautman
*/
public class UtilitiesTest {

@Test
public void testTileIdParsers() {
final String tileId = "w60_magc0399_scan005_m0013_s001";
Assert.assertEquals("invalid MFOVForTileId",
"0399_m0013", Utilities.getMFOVForTileId(tileId));
Assert.assertEquals("invalid SFOVForTileId",
"0399_m0013_s001", Utilities.getSFOVForTileId(tileId));
Assert.assertEquals("invalid SFOVIndexForTileId",
"001", Utilities.getSFOVIndexForTileId(tileId));
}

}

0 comments on commit 0231dff

Please sign in to comment.