Skip to content
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

[Project] Medical semantic seg dataset: 2pm vessel #2685

Merged
merged 26 commits into from
Jun 25, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
a104395
Update 8 datasets following template made by tianbinli at Feb. 20
Masaaki-75 Feb 21, 2023
9c2791b
Delete projects/example_project directory
Masaaki-75 Feb 22, 2023
f491633
Delete projects/hssn directory
Masaaki-75 Feb 22, 2023
900d079
Delete projects/isnet directory
Masaaki-75 Feb 22, 2023
38932b4
Delete projects/mapillary_dataset directory
Masaaki-75 Feb 22, 2023
51b8892
scripts for project of medical dataset (modality=ct).
Masaaki-75 Mar 2, 2023
5e50996
scripts for project of medical dataset cranium (modality=ct).
Masaaki-75 Mar 2, 2023
da389c5
scripts for project of medical dataset endovis15 (modality=endoscopy).
Masaaki-75 Mar 2, 2023
7ec8087
Merge branch 'dev-1.x' of https://github.com/Masaaki-75/mmsegmentatio…
Masaaki-75 Mar 2, 2023
dd29bcf
scripts for project of medical dataset endovis15 (modality=endoscopy).
Masaaki-75 Mar 2, 2023
dd5356f
scripts for project of medical dataset kvasir_seg (modality=endoscopy).
Masaaki-75 Mar 2, 2023
1300566
scripts for project of medical dataset kvasir_seg_aliyun (modality=en…
Masaaki-75 Mar 2, 2023
79357f0
scripts for project of medical dataset gamma (modality=fundus_photogr…
Masaaki-75 Mar 2, 2023
605ecd6
scripts for project of medical dataset rite (modality=fundus_photogra…
Masaaki-75 Mar 2, 2023
f49066c
scripts for project of medical dataset bcss (modality=histopathology).
Masaaki-75 Mar 2, 2023
b94a6db
scripts for project of medical dataset fusc2021 (modality=histopathol…
Masaaki-75 Mar 2, 2023
667d3a4
scripts for project of medical dataset pannuke (modality=histopatholo…
Masaaki-75 Mar 2, 2023
443f605
scripts for project of medical dataset pcam (modality=histopathology).
Masaaki-75 Mar 2, 2023
ae08b20
scripts for project of medical dataset 2pm_vessel (modality=microscop…
Masaaki-75 Mar 2, 2023
04363df
updated scripts for project of medical dataset 2pm_vessel (modality=m…
Masaaki-75 Mar 3, 2023
a47db1c
updated scripts for project of medical dataset 2pm_vessel (modality=m…
Masaaki-75 Mar 28, 2023
0b93699
--fix=restore
xiexinch Jun 25, 2023
ef2a795
Merge remote-tracking branch 'upstream/dev-1.x' into 2pm_vessel
xiexinch Jun 25, 2023
98102c0
--other=fix script
xiexinch Jun 25, 2023
4c9e0fe
--doc=remove results
xiexinch Jun 25, 2023
49a2cfc
--other=rename config
xiexinch Jun 25, 2023
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
Prev Previous commit
Next Next commit
--other=fix script
  • Loading branch information
xiexinch committed Jun 25, 2023
commit 98102c0e863338ef649cfc3df748c4e5073b0f54
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ export PYTHONPATH=`pwd`:$PYTHONPATH
- run script `"python tools/prepare_dataset.py"` to format data and change folder structure as below.
- run script `"python ../../tools/split_seg_dataset.py"` to split dataset and generate `train.txt`, `val.txt` and `test.txt`. If the label of official validation set and test set can't be obtained, we generate `train.txt` and `val.txt` from the training set randomly.

```shell
mkdir data & cd data
pip install opendatalab
odl get 2-PM_Vessel_Dataset
cd ..
python tools/prepare_dataset.py
python tools/prepare_dataset.py
```

```none
mmsegmentation
├── mmseg
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@

root_path = 'data/'

src_dir = os.path.join(root_path, '2-PM_Vessel_Dataset')
image_dir = os.path.join(root_path,
'2-PM_Vessel_Dataset/raw/vesselNN_dataset/denoised')
label_dir = os.path.join(root_path,
'2-PM_Vessel_Dataset/raw/vesselNN_dataset/labels')
tgt_img_train_dir = os.path.join(root_path, 'images/train/')
tgt_mask_train_dir = os.path.join(root_path, 'masks/train/')
os.system('mkdir -p ' + tgt_img_train_dir)
Expand All @@ -19,23 +22,25 @@ def filter_suffix(src_dir, suffix):
return sorted(file_paths), sorted(file_names)


path_list, _ = filter_suffix(src_dir, suffix='.tif')

for path_label in path_list:
labels = tiff.imread(path_label)
assert labels.ndim == 3
path_image = path_label.replace('_label', '')
name = path_image.split('/')[-1].replace('.tif', '')
images = tiff.imread(path_image)
assert images.shape == labels.shape
# a single .tif file contains multiple slices
# as long as it is read by tifffile package.
for i in range(labels.shape[0]):
slice_name = name + '_' + str(i).rjust(3, '0') + '.png'
image = images[i]
label = labels[i] // 255

save_path_label = os.path.join(tgt_mask_train_dir, slice_name)
Image.fromarray(label).save(save_path_label)
save_path_image = os.path.join(tgt_img_train_dir, slice_name)
Image.fromarray(image).convert('RGB').save(save_path_image)
if __name__ == '__main__':

image_path_list, _ = filter_suffix(image_dir, suffix='tif')
label_path_list, _ = filter_suffix(label_dir, suffix='.tif')

for img_path, label_path in zip(image_path_list, label_path_list):
labels = tiff.imread(label_path)
images = tiff.imread(img_path)
assert labels.ndim == 3
assert images.shape == labels.shape
name = img_path.split('/')[-1].replace('.tif', '')
# a single .tif file contains multiple slices
# as long as it is read by tifffile package.
for i in range(labels.shape[0]):
slice_name = name + '_' + str(i).rjust(3, '0') + '.png'
image = images[i]
label = labels[i] // 255

save_path_label = os.path.join(tgt_mask_train_dir, slice_name)
Image.fromarray(label).save(save_path_label)
save_path_image = os.path.join(tgt_img_train_dir, slice_name)
Image.fromarray(image).convert('RGB').save(save_path_image)