Skip to content

Commit

Permalink
allow nucleusNumber field/column to be empty to work with non-nuclei-…
Browse files Browse the repository at this point in the history
…filtered input
  • Loading branch information
vreuter committed Nov 18, 2024
1 parent 7b2ed29 commit 15aa65b
Showing 1 changed file with 6 additions and 8 deletions.
14 changes: 6 additions & 8 deletions src/main/scala/AssignTraceIds.scala
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ object AssignTraceIds extends ScoptCliReaders, StrictLogging:
centroid: Centroid[Double],
box: BoundingBox,
maybeMergeInputs: Set[RoiIndex], // may be empty, as the input collection is possibly a mix of singletons and merge results
maybeNucleusNumber: Option[NucleusNumber], // allow the program to operate on non-nuclei-filtered ROIs.
maybeNucleusNumber: Option[NucleusNumber], // Allow the program to operate on non-nuclei-filtered ROIs.
):
final def timepoint: ImagingTimepoint = context.timepoint

Expand All @@ -354,13 +354,11 @@ object AssignTraceIds extends ScoptCliReaders, StrictLogging:
MergeContributorsColumnNameForAssessedRecord.from(row)
val nucNel: ValidatedNel[String, Option[NucleusNumber]] =
val key = NucleusDesignationColumnName.value
row.apply(key)
.toRight(s"Missing header/field '$key'")
.flatMap{
case "" => None.asRight
case s => NucleusNumber.parse(s).map(_.some)
}
.toValidatedNel
row.apply(key) match {
// Allow the program to operate on non-nuclei-filtered ROIs.
case None | Some("") => Option.empty.validNel
case Some(s) => NucleusNumber.parse(s).map(_.some).toValidatedNel
}
(spotNel, mergeInputsNel, nucNel)
.mapN{ (spot, maybeMergeIndices, maybeNucNum) =>
InputRecord(spot.index, spot.context, spot.centroid, spot.box, maybeMergeIndices, maybeNucNum)
Expand Down

0 comments on commit 15aa65b

Please sign in to comment.