also record diameter and size
This commit is contained in:
parent
4f4e8f8882
commit
18df7a2d4f
2 changed files with 33 additions and 5 deletions
|
|
@ -22,6 +22,7 @@ INCLUDED_HASH = [
|
||||||
|
|
||||||
|
|
||||||
LAST_DAY = datetime.datetime.strptime("2025-11-01", "%Y-%m-%d")
|
LAST_DAY = datetime.datetime.strptime("2025-11-01", "%Y-%m-%d")
|
||||||
|
MAX_PATIENT = 10//3
|
||||||
|
|
||||||
SRC_ROOT = "/mnt/t24/Public/kimo/TSHA"
|
SRC_ROOT = "/mnt/t24/Public/kimo/TSHA"
|
||||||
RAW_DIR = "/mnt/t24/Public/kimo/raw/"
|
RAW_DIR = "/mnt/t24/Public/kimo/raw/"
|
||||||
|
|
@ -217,6 +218,8 @@ def main():
|
||||||
for patho in sorted(os.listdir(SRC_ROOT)):
|
for patho in sorted(os.listdir(SRC_ROOT)):
|
||||||
patho_dir = os.path.join(SRC_ROOT, patho)
|
patho_dir = os.path.join(SRC_ROOT, patho)
|
||||||
|
|
||||||
|
num_patient = 0
|
||||||
|
|
||||||
for patient in sorted(os.listdir(patho_dir)):
|
for patient in sorted(os.listdir(patho_dir)):
|
||||||
md5, hash = hashptid(patient)
|
md5, hash = hashptid(patient)
|
||||||
|
|
||||||
|
|
@ -268,7 +271,9 @@ def main():
|
||||||
if num_study > 0:
|
if num_study > 0:
|
||||||
with open(complete_file, 'w') as f:
|
with open(complete_file, 'w') as f:
|
||||||
f.write('done')
|
f.write('done')
|
||||||
# break
|
num_patient += 1
|
||||||
|
if num_patient >= MAX_PATIENT:
|
||||||
|
break
|
||||||
# break
|
# break
|
||||||
print(NII_DICT)
|
print(NII_DICT)
|
||||||
logging.info(f"BodyPartExamined: {BodyPartExamined}")
|
logging.info(f"BodyPartExamined: {BodyPartExamined}")
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@ import shutil
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
|
|
||||||
import numpy as np
|
import numpy as np
|
||||||
|
import pandas as pd
|
||||||
import SimpleITK as sitk
|
import SimpleITK as sitk
|
||||||
|
|
||||||
ROOT_DIR = "/mnt/t24/Public/kimo/"
|
ROOT_DIR = "/mnt/t24/Public/kimo/"
|
||||||
|
|
@ -99,8 +100,14 @@ def contour_overlay(image_nii, label_nii):
|
||||||
logging.warning(f"No label found in {label_nii}")
|
logging.warning(f"No label found in {label_nii}")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
print(stats.GetPhysicalSize(1))
|
if stats.GetPhysicalSize(1) < 1000:
|
||||||
exit()
|
logging.warning(f"Label size too small in {label_nii}")
|
||||||
|
return None
|
||||||
|
|
||||||
|
# print(stats.GetFeretDiameter(1))
|
||||||
|
# print(stats.GetEquivalentEllipsoidDiameter(1))
|
||||||
|
# print(stats.GetPhysicalSize(1))
|
||||||
|
# exit()
|
||||||
|
|
||||||
center_idx = largest.TransformPhysicalPointToIndex(stats.GetCentroid(1))
|
center_idx = largest.TransformPhysicalPointToIndex(stats.GetCentroid(1))
|
||||||
|
|
||||||
|
|
@ -162,9 +169,11 @@ def contour_overlay(image_nii, label_nii):
|
||||||
|
|
||||||
return {
|
return {
|
||||||
'contour_image': Image.fromarray(row_con),
|
'contour_image': Image.fromarray(row_con),
|
||||||
'overlay_image': combined_img
|
'overlay_image': combined_img,
|
||||||
|
'stats': stats,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DATALIST = []
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
FORMAT = '%(asctime)s [%(filename)s:%(lineno)d] %(message)s'
|
FORMAT = '%(asctime)s [%(filename)s:%(lineno)d] %(message)s'
|
||||||
|
|
@ -213,10 +222,24 @@ def main():
|
||||||
|
|
||||||
shutil.copyfile(image_nii, f"{dest_dir}/image.nii.gz")
|
shutil.copyfile(image_nii, f"{dest_dir}/image.nii.gz")
|
||||||
shutil.copyfile(label_nii, f"{dest_dir}/label.nii.gz")
|
shutil.copyfile(label_nii, f"{dest_dir}/label.nii.gz")
|
||||||
copytree(dicomdir, f"{dest_dir}/DICOM")
|
# copytree(dicomdir, f"{dest_dir}/DICOM")
|
||||||
|
|
||||||
CASE_SET.add(hash)
|
CASE_SET.add(hash)
|
||||||
# exit()
|
# exit()
|
||||||
|
|
||||||
|
DATALIST.append({
|
||||||
|
"Category": category,
|
||||||
|
"Stem": stem,
|
||||||
|
"EquivalentEllipsoidDiameter": con_ov['stats'].GetEquivalentEllipsoidDiameter(1),
|
||||||
|
"PhysicalSize": con_ov['stats'].GetPhysicalSize(1),
|
||||||
|
# "dicomdir": dicomdir,
|
||||||
|
# "image_nii": image_nii,
|
||||||
|
# "label_nii": label_nii,
|
||||||
|
# "dest_dir": dest_dir,
|
||||||
|
})
|
||||||
|
|
||||||
|
df = pd.DataFrame(DATALIST)
|
||||||
|
df.to_excel(f"{FINAL_DIR}/datalist.xlsx", index=False)
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
main()
|
main()
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue