Closed bryanwong17 closed 1 year ago
Hi @bryanwong17
You can use create_patches.py
(without fast-patching mode) to save [256 x 256] patches in CLAM.
Hi @Richarizardd, I tried using this command:
python create_patches.py --source DATA_DIRECTORY --save_dir RESULTS_DIRECTORY --patch_size 256 --seg --patch --stitch
However, I still couldn't get raw [256 x 256 patches] (as *.png format). Is there something wrong?
hi @bryanwong17, my understanding is that create_patches.py
will store image patches as numpy arrays under the imgs
dataset in the h5py
file saved to disk.
You can either:
write a small script that opens each h5py
file & save corresponding numpy arrays to disk as png images
add the following lines here and re-run create_patches.py
(it'll save each patch based on its x
and y
coordinates)
pil_patch = Image.fromarray(img_patch)
patch_save_path = os.path.join(save_path, name, f'{x}_{y}.png')
if not os.path.isdir(os.path.join(save_path, name)):
os.mkdir(os.path.join(save_path, name))
pil_patch.save(patch_save_path)
hope it was helpful
Hi @clemsgrs, I was able to extract patches in .png format. In this case, what do x and y represent? Are they representing the actual location in the slide? Does that mean we do not have to multiply again, let's say with 256?
hi, x
and y
coordinates should represent the true location in the slide at level 0.
if pixel spacing is 0.25
at level 0 and you extract [256, 256] patches at spacing 0.5
, then it corresponds to extracting [512, 512] patches at spacing 0.25
; thus two consecutive patches will have a 512
value difference (either in x
or y
coordinates).
might be better to update coordinates based on spacing, will give it a thought
Hi @Richarizardd,
May I know how to get raw [256 × 256] patches (as *.png format) after CLAM processing?