Skip to content

Commit

Permalink
make type generic
Browse files Browse the repository at this point in the history
  • Loading branch information
kapoorlab committed Apr 14, 2024
1 parent d218c0f commit b785226
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@

<groupId>sc.fiji</groupId>
<artifactId>TrackMate-Oneat</artifactId>
<version>3.2.5-SNAPSHOT</version>
<version>3.2.6-SNAPSHOT</version>


<name>TrackMate-Oneat</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -816,20 +816,39 @@ private static <T extends NativeType<T>> Ellipsoid getEllipsoid(Spot currentspot

long[] location = new long[ndim - 1];
RandomAccess<T> ranac = frameimg.randomAccess();
int label= 0, checklabel= 0;
for (int d = 0; d < ndim - 1; ++d) {
location[d] = (long) (currentspot.getDoublePosition(d) / calibration[d]);
ranac.setPosition(location[d], d);
}

int label = (int) ( (UnsignedShortType) ranac.get()).get();

String pixelType = ranac.get().getClass().getSimpleName();
if ("UnsignedShortType".equals(pixelType)) {
label = (int) ((UnsignedShortType) ranac.get()).get();
} else if ("FloatType".equals(pixelType)) {
label = (int) ((FloatType) ranac.get()).get();
} else {
throw new IllegalArgumentException("Unsupported pixel type: " + pixelType);
}


Cursor<T> cur = frameimg.localizingCursor();
ArrayList<Localizable> points = new ArrayList<Localizable>();
while (cur.hasNext()) {

cur.fwd();



if ((int) ( (UnsignedShortType) cur.get()).get() == label) {
if ("UnsignedShortType".equals(pixelType)) {
checklabel = (int) ((UnsignedShortType) cur.get()).get();
} else if ("FloatType".equals(pixelType)) {
checklabel = (int) ((FloatType) cur.get()).get();
} else {
throw new IllegalArgumentException("Unsupported pixel type: " + pixelType);
}

if (checklabel == label) {

long[] point = new long[center.length];
for (int d = 0; d < center.length; d++) {
Expand Down Expand Up @@ -966,7 +985,21 @@ public static <T extends NativeType<T>> Pair<HashMap<Pair<Integer, Integer>, Pai
}

ranac.setPosition(frame, ndim);
int label = (int) ( (UnsignedShortType) ranac.get()).get();

int label = 0;

String pixelType = ranac.get().getClass().getSimpleName();

if ("UnsignedShortType".equals(pixelType)) {
label = (int) ((UnsignedShortType) ranac.get()).get();
} else if ("FloatType".equals(pixelType)) {
label = (int) ((FloatType) ranac.get()).get();
} else {
throw new IllegalArgumentException("Unsupported pixel type: " + pixelType);
}




uniquelabelID.put(new ValuePair<Integer, Integer>(label, frame),
new ValuePair<Spot, Integer>(spot, trackID));
Expand Down Expand Up @@ -1015,7 +1048,20 @@ public static <T extends NativeType<T>> HashMap<Integer, Pair<Spot, Spot>> geta
}
ranac.setPosition(frame, ndim);
ArrayList<Integer> Alllabels = new ArrayList<Integer>();
int labelID = (int) ( (UnsignedShortType) ranac.get()).get();
int labelID = 0;

String pixelType = ranac.get().getClass().getSimpleName();

if ("UnsignedShortType".equals(pixelType)) {
labelID = (int) ((UnsignedShortType) ranac.get()).get();
} else if ("FloatType".equals(pixelType)) {
labelID = (int) ((FloatType) ranac.get()).get();
} else {
throw new IllegalArgumentException("Unsupported pixel type: " + pixelType);
}



if (labelID != 0)
Alllabels.add(labelID);

Expand Down Expand Up @@ -1089,7 +1135,20 @@ public static <T extends NativeType<T>> HashMap<Integer, Pair<Spot, ArrayList<Sp
ranac.setPosition(frame, ndim);

ArrayList<Integer> Alllabels = new ArrayList<Integer>();
int labelID = (int) ( (UnsignedShortType) ranac.get()).get();
int labelID = 0;

String pixelType = ranac.get().getClass().getSimpleName();

if ("UnsignedShortType".equals(pixelType)) {
labelID = (int) ((UnsignedShortType) ranac.get()).get();
} else if ("FloatType".equals(pixelType)) {
labelID = (int) ((FloatType) ranac.get()).get();
} else {
throw new IllegalArgumentException("Unsupported pixel type: " + pixelType);
}



if (labelID != 0)
Alllabels.add(labelID);

Expand Down Expand Up @@ -1186,7 +1245,18 @@ private static <T extends NativeType<T>> SimpleWeightedGraph<Spot, DefaultWeight
}
ranac.setPosition(frame, ndim);
// Get the label ID of the current interesting spot
int labelID = (int) ( (UnsignedShortType) ranac.get()).get();
int labelID = 0;
String pixelType = ranac.get().getClass().getSimpleName();

if ("UnsignedShortType".equals(pixelType)) {
labelID = (int) ((UnsignedShortType) ranac.get()).get();
} else if ("FloatType".equals(pixelType)) {
labelID = (int) ((FloatType) ranac.get()).get();
} else {
throw new IllegalArgumentException("Unsupported pixel type: " + pixelType);
}



if (uniquelabelID.containsKey(new ValuePair<Integer, Integer>(labelID, frame))) {
Pair<Spot, Integer> spotandtrackID = uniquelabelID
Expand Down

0 comments on commit b785226

Please sign in to comment.