- # print(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'infarctus'), cas, dic)) # Testing..
- topng(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'infarctus'), cas, dic))
- else:
- # print("no infarctus:", infarctus) # Testing..
- # print(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'noinfarctus'), cas, dic)) # Testing..
- topng(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'noinfarctus'), cas, dic))
-
- print('Ended!')
\ No newline at end of file
+ # print('epimask', epimask)
+
+ # debug <<
+ # epimask = False
+ # debug >>
+
+ if epimask:# this condition could be if necessary
+ if infarctus and (END_INF_CASES is not None) and j > END_INF_CASES:
+ continue
+ if not infarctus and (END_NOINF_CASES is not None) and j > END_NOINF_CASES:
+ continue
+ # topng(join(caspath, dic), '{}/{}-{}'.format(join(OUT_DIR, 'infarctus' if infarctus else 'noinfarctus'), cas, dic), epimask=epimask['path'] if epimask else None)
+ # img_, dicimg_, minmax_ = topng(join(caspath, dic),
+ # '{}/{}-{}'.format(join(OUT_DIR, 'infarctus' if infarctus else 'noinfarctus'), cas, dic),
+ # epimask=epimask['path'] if epimask else None,
+ # verbose=True,
+ # )
+
+ # Possibly data augmentation purpose here
+ print("EPI_MIN_PIXELS", EPI_MIN_PIXELS)
+ topng(
+ join(caspath, dic),
+ outfile='{}/crop-mask/{}-{}'.format(join(OUT_DIR,
+ 'infarctus' if infarctus else 'noinfarctus'),
+ cas,
+ dic,
+ ),
+ epimask=epimask['path'] if epimask else None,
+ centercrop=CROP_SIZE,
+ blackmask=True,
+ epiminpixels=EPI_MIN_PIXELS
+ ) # crop and mask with black
+
+ # if endomask:
+ # topng(
+ # join(caspath, dic),
+ # outfile='{}/crop-mask-hollow/{}-{}'.format(join(OUT_DIR,
+ # 'infarctus' if infarctus else 'noinfarctus'),
+ # cas,
+ # dic,
+ # ),
+ # epimask=epimask['path'] if epimask else None,
+ # endomask=endomask['path'] if endomask else None,
+ # centercrop=CROP_SIZE,
+ # blackmask=True,
+ # ) # crop and (mask and fill hollow) with black
+
+ # topng(
+ # join(caspath, dic),
+ # outfile='{}/crop-nomask/{}-{}'.format(join(OUT_DIR,
+ # 'infarctus' if infarctus else 'noinfarctus'),
+ # cas,
+ # dic,
+ # ),
+ # epimask=epimask['path'] if epimask else None,
+ # centercrop=CROP_SIZE,
+ # ) # just crop, don't apply black mask
+
+ # w, h = BE CAREFULL, be sure w, h is needed, and that topng returns something
+ # topng(
+ # join(caspath, dic),
+ # outfile='{}/contour/{}-{}'.format(join(OUT_DIR,
+ # 'infarctus' if infarctus else 'noinfarctus'),
+ # cas,
+ # dic,
+ # ),
+ # epimask=epimask['path'] if epimask else None,
+ # redcontour=True,
+ # ) # draw a red contour for visibily purpose
+
+ # segmentation width & height <<
+ # xmin, ymin, xmax, ymax = minmax_
+ # w = xmax - xmin + 1 # +1 : even the position takes a bit
+ # h = ymax - ymin + 1
+ # segmentation width & height >>
+
+
+ # # search maximums
+ # if wmax < w: wmax = w
+ # if hmax < h: hmax = h
+
+ # # search width minimum
+ # if wmin is None: wmin = w
+ # elif wmin > w: wmin = w
+
+ # # search height minimum
+ # if hmin is None: hmin = h
+ # elif hmin > h: hmin = h
+ # except Exception as e:
+ # print("WARN", "something went wrong with this image", dic, str(e))
+ # continue
+
+
+ # print('min-width, max-width:', (wmin, wmax))
+ # print('min-height, max-height:', (hmin, hmax))
+
+ # print('Ended!')