Skip to content

WIP: Option to invert color layer when starting neuron inferral #8796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions app/controllers/AiModelController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,8 @@ case class RunInferenceParameters(annotationId: Option[ObjectId],
boundingBox: String,
newDatasetName: String,
maskAnnotationLayerName: Option[String],
workflowYaml: Option[String])
workflowYaml: Option[String],
invertColorLayer: Option[Boolean])

object RunInferenceParameters {
implicit val jsonFormat: OFormat[RunInferenceParameters] = Json.format[RunInferenceParameters]
Expand Down Expand Up @@ -196,7 +197,8 @@ class AiModelController @Inject()(
"model_id" -> request.body.aiModelId,
"dataset_directory_name" -> request.body.datasetDirectoryName,
"new_dataset_name" -> request.body.newDatasetName,
"custom_workflow_provided_by_user" -> request.body.workflowYaml
"custom_workflow_provided_by_user" -> request.body.workflowYaml,
"invert_color_layer" -> request.body.invertColorLayer
)
newInferenceJob <- jobService.submitJob(jobCommand, commandArgs, request.identity, dataStore.name) ?~> "job.couldNotRunInferWithModel"
newAiInference = AiInference(
Expand Down
12 changes: 9 additions & 3 deletions app/controllers/JobController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,10 @@ class JobController @Inject()(jobDAO: JobDAO,
} yield Ok(js)
}

def runInferNucleiJob(datasetId: ObjectId, layerName: String, newDatasetName: String): Action[AnyContent] =
def runInferNucleiJob(datasetId: ObjectId,
layerName: String,
newDatasetName: String,
invertColorLayer: Option[Boolean]): Action[AnyContent] =
sil.SecuredAction.async { implicit request =>
log(Some(slackNotificationService.noticeFailedJobRequest)) {
for {
Expand All @@ -220,7 +223,8 @@ class JobController @Inject()(jobDAO: JobDAO,
"dataset_name" -> dataset.name,
"dataset_directory_name" -> dataset.directoryName,
"layer_name" -> layerName,
"new_dataset_name" -> newDatasetName
"new_dataset_name" -> newDatasetName,
"invert_color_layer" -> invertColorLayer
)
job <- jobService.submitJob(command, commandArgs, request.identity, dataset._dataStore) ?~> "job.couldNotRunNucleiInferral"
js <- jobService.publicWrites(job)
Expand All @@ -237,7 +241,8 @@ class JobController @Inject()(jobDAO: JobDAO,
evalUseSparseTracing: Option[Boolean],
evalMaxEdgeLength: Option[Double],
evalSparseTubeThresholdNm: Option[Double],
evalMinMergerPathLengthNm: Option[Double]): Action[AnyContent] =
evalMinMergerPathLengthNm: Option[Double],
invertColorLayer: Option[Boolean]): Action[AnyContent] =
sil.SecuredAction.async { implicit request =>
log(Some(slackNotificationService.noticeFailedJobRequest)) {
for {
Expand Down Expand Up @@ -267,6 +272,7 @@ class JobController @Inject()(jobDAO: JobDAO,
"eval_max_edge_length" -> evalMaxEdgeLength,
"eval_sparse_tube_threshold_nm" -> evalSparseTubeThresholdNm,
"eval_min_merger_path_length_nm" -> evalMinMergerPathLengthNm,
"invert_color_layer" -> invertColorLayer
)
creditTransactionComment = s"AI neuron segmentation for dataset ${dataset.name}"
jobAsJs <- jobService.submitPaidJob(command,
Expand Down
4 changes: 2 additions & 2 deletions conf/webknossos.latest.routes
Original file line number Diff line number Diff line change
Expand Up @@ -255,8 +255,8 @@ POST /jobs/run/convertToWkw/:datasetId
POST /jobs/run/computeMeshFile/:datasetId controllers.JobController.runComputeMeshFileJob(datasetId: ObjectId, layerName: String, mag: String, agglomerateView: Option[String])
POST /jobs/run/computeSegmentIndexFile/:datasetId controllers.JobController.runComputeSegmentIndexFileJob(datasetId: ObjectId, layerName: String)
POST /jobs/run/exportTiff/:datasetId controllers.JobController.runExportTiffJob(datasetId: ObjectId, bbox: String, additionalCoordinates: Option[String], layerName: Option[String], mag: Option[String], annotationLayerName: Option[String], annotationId: Option[ObjectId], asOmeTiff: Boolean)
POST /jobs/run/inferNuclei/:datasetId controllers.JobController.runInferNucleiJob(datasetId: ObjectId, layerName: String, newDatasetName: String)
POST /jobs/run/inferNeurons/:datasetId controllers.JobController.runInferNeuronsJob(datasetId: ObjectId, layerName: String, bbox: String, newDatasetName: String, doSplitMergerEvaluation: Boolean, annotationId: Option[String], evalUseSparseTracing: Option[Boolean], evalMaxEdgeLength: Option[Double], evalSparseTubeThresholdNm: Option[Double], evalMinMergerPathLengthNm: Option[Double])
POST /jobs/run/inferNuclei/:datasetId controllers.JobController.runInferNucleiJob(datasetId: ObjectId, layerName: String, newDatasetName: String, invertColorLayer: Option[Boolean])
POST /jobs/run/inferNeurons/:datasetId controllers.JobController.runInferNeuronsJob(datasetId: ObjectId, layerName: String, bbox: String, newDatasetName: String, doSplitMergerEvaluation: Boolean, annotationId: Option[String], evalUseSparseTracing: Option[Boolean], evalMaxEdgeLength: Option[Double], evalSparseTubeThresholdNm: Option[Double], evalMinMergerPathLengthNm: Option[Double], invertColorLayer: Option[Boolean])
POST /jobs/run/inferMitochondria/:datasetId controllers.JobController.runInferMitochondriaJob(datasetId: ObjectId, layerName: String, bbox: String, newDatasetName: String)
POST /jobs/run/alignSections/:datasetId controllers.JobController.runAlignSectionsJob(datasetId: ObjectId, layerName: String, newDatasetName: String, annotationId: Option[ObjectId])
POST /jobs/run/materializeVolumeAnnotation/:datasetId controllers.JobController.runMaterializeVolumeAnnotationJob(datasetId: ObjectId, fallbackLayerName: String, annotationId: ObjectId, annotationType: String, newDatasetName: String, outputSegmentationLayerName: String, mergeSegments: Boolean, volumeLayerName: Option[String], includesEditableMapping: Boolean, boundingBox: Option[String])
Expand Down
22 changes: 16 additions & 6 deletions frontend/javascripts/admin/api/jobs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -191,13 +191,18 @@ export function startNucleiInferralJob(
datasetId: string,
layerName: string,
newDatasetName: string,
invertColorLayer?: boolean,
): Promise<APIJob> {
return Request.receiveJSON(
`/api/jobs/run/inferNuclei/${datasetId}?layerName=${layerName}&newDatasetName=${newDatasetName}`,
{
method: "POST",
},
);
const urlParams = new URLSearchParams({
layerName,
newDatasetName,
});
if (invertColorLayer != null) {
urlParams.append("invertColorLayer", `${invertColorLayer}`);
}
return Request.receiveJSON(`/api/jobs/run/inferNuclei/${datasetId}?${urlParams.toString()}`, {
method: "POST",
});
}

export function startNeuronInferralJob(
Expand All @@ -211,6 +216,7 @@ export function startNeuronInferralJob(
evalMaxEdgeLength?: number,
evalSparseTubeThresholdNm?: number,
evalMinMergerPathLengthNm?: number,
invertColorLayer?: boolean,
): Promise<APIJob> {
const urlParams = new URLSearchParams({
layerName,
Expand All @@ -236,6 +242,9 @@ export function startNeuronInferralJob(
urlParams.append("evalMinMergerPathLengthNm", `${evalMinMergerPathLengthNm}`);
}
}
if (invertColorLayer != null) {
urlParams.append("invertColorLayer", `${invertColorLayer}`);
}
return Request.receiveJSON(`/api/jobs/run/inferNeurons/${datasetId}?${urlParams.toString()}`, {
method: "POST",
});
Expand Down Expand Up @@ -384,6 +393,7 @@ type RunInferenceParameters = {
boundingBox: Vector6;
newDatasetName: string;
workflowYaml?: string;
invertColorLayer?: boolean;
// maskAnnotationLayerName?: string | null
};

Expand Down
2 changes: 2 additions & 0 deletions unreleased_changes/8796.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
### Added
- When starting an inference job on a dataset with inverted intensity values, that inversion now also applies in the inference job.