Skip to content

Commit

Permalink
Added enrichments to dicom-seg files from monailabel serving endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
erinaldidb committed Nov 11, 2024
1 parent b53ef38 commit 690d62f
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion workflow/process_dicom-seg_generated.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,18 @@

from dbx.pixels import Catalog
from dbx.pixels.dicom import DicomMetaExtractor
from pyspark.sql.functions import expr

catalog = Catalog(spark, table=table, volume=volume)
catalog_df = catalog.catalog(path=path, streaming=True, streamCheckpointBasePath=f"{catalog._volume_path}/checkpoints/monai_label_segm/")

catalog_df = spark.readStream.table(table+"_autoseg_result").selectExpr("concat('dbfs:', nullif(result, '')) as path").where('path is not null')
catalog_df = Catalog._with_path_meta(catalog_df)

meta_df = DicomMetaExtractor(catalog).transform(catalog_df)
meta_df = DicomMetaExtractor(catalog, deep=False).transform(catalog_df)
meta_df = meta_df\
.withColumn("modificationTime", expr("to_timestamp(unix_timestamp(concat(meta:['00080023'].Value[0], meta:['00080033'].Value[0]), 'yyyyMMddHHmmss'))"))\
.withColumn("length", expr("meta:['file_size']").cast("bigint"))


catalog.save(meta_df, mode="append")

0 comments on commit 690d62f

Please sign in to comment.