diff --git a/.devcontainer/Dockerfile b/.devcontainer/Dockerfile new file mode 100644 index 0000000..1807e69 --- /dev/null +++ b/.devcontainer/Dockerfile @@ -0,0 +1,23 @@ +FROM python:3.8-slim + +RUN apt-get update && apt-get upgrade -y +RUN apt-get install -y \ + libgl1-mesa-dev \ + libglib2.0-0 \ + libsm6 \ + libxext6 \ + libxrender-dev \ + libx11-dev + +COPY ./requirements.txt ./ + +RUN pip3 install --upgrade pip setuptools +RUN pip3 install --upgrade wheel +RUN pip3 install -r requirements.txt + +ENV DISPLAY=host.docker.internal:0.0 + +WORKDIR /code +ADD . . + +CMD python3 main.py diff --git a/.devcontainer/devcontainer.json b/.devcontainer/devcontainer.json new file mode 100644 index 0000000..dbac373 --- /dev/null +++ b/.devcontainer/devcontainer.json @@ -0,0 +1,35 @@ +{ + "name": "sato_container", + // Dockerfileでイメージ・コンテナを作成 + "context": "..", + "dockerFile": "Dockerfile", + // リモート先のVS Codeにインストールする拡張機能 + "extensions": [ + "ms-python.python" + ], + "settings": { + // 構文チェックを行うようにする + "python.linting.enabled": true, + // 保存時に構文チェックを行う + "python.linting.lintOnSave": true, + // 構文チェックをpylintで行わないようにする (※規定値がtrueなため) + "python.linting.pylintEnabled": false, + // 構文チェックをflake8で行うようにする + "python.linting.flake8Enabled": true, + // flake8のパス (※pyproject-flake8を導入している場合はpflake8で上書きする必要がある) + "python.linting.flake8Path": "/usr/local/bin/pflake8", + // mypyを有効化する + "python.linting.mypyEnabled": true, + // フォーマットをblackで行うようにする + "python.formatting.provider": "black", + // pythonファイルの設定 + "[python]": { + // 保存時にimport文のソートなどを行う + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + // 保存時にフォーマットを行う + "editor.formatOnSave": true + } + }, +} \ No newline at end of file diff --git a/.gitignore b/.gitignore index e158169..f86a692 100644 --- a/.gitignore +++ b/.gitignore @@ -128,6 +128,6 @@ # Pyre type checker .pyre/ -.devcontainer/ -.vscode/* +.vscode/ +.mypy_cache/ diff --git a/README.md b/README.md index e59195a..688a6c4 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,17 @@ CollectAnimalExperimentLabels2021 =============== -上里先生と使用した動物実験における正解クリップ位置を収集するためのGUIアプリケーション \ No newline at end of file +上里先生と使用した動物実験における正解クリップ位置を収集するためのGUIアプリケーション + +
+ +--- + +## 準備 +- main.py中の"dicom_dirs"に読み込みたいDICOMディレクトリを指定する. +- Xserver(WindowsだったらVcXsrvとか)を立ち上げておく +## 稼働方法 +1. イメージのビルド +docker build -f .devcontainer/Dockerfile -t collect_label . +2. コンテナの稼働 +docker build run -it collect_label diff --git a/main.py b/main.py index ed9026b..4094156 100644 --- a/main.py +++ b/main.py @@ -1,15 +1,16 @@ import csv -import pydicom -from glob import glob -import cv2 -import pickle -import numpy as np import os.path as osp +import pickle +from glob import glob + +import cv2 +import numpy as np +import pydicom from tqdm import tqdm -dicom_dirs = r"D:\Animal_experiment_CT\DICOM" +dicom_dirs = "./DICOM" load_tmp1 = False -load_tmp2 = True +load_tmp2 = False save_num = 0 while True: @@ -78,6 +79,8 @@ mx, my = 0, 0 results = [] + + def mouseCallbackFunc(event, x, y, flags, param): global files, img_index, mx, my, csv_writer, f, results mx, my = x, y @@ -109,7 +112,7 @@ img_index = 0 while True: k = cv2.waitKey(10) - if k == ord('l') and img_index != (file_size - 1): + if k == ord("l") and img_index != (file_size - 1): img_index += 1 print(f"img_index: {img_index}") CT_img = getImgByIndex(files, img_index, dcm_wc, dcm_ww) diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..9d84e25 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,29 @@ +[tool.isort] +profile = "black" +line_length = 120 +skip_glob = "*/migrations/*.py" + +[tool.black] +line-length = 120 +include = '\.pyi?$' +extend-exclude = ''' +/( + | \.git + | templates + | migrations +)/ +''' + +[tool.flake8] +max-line-length = 120 +extend-ignore = "E203,W503" + + +[tool.mypy] +follow-imports = "normal" +ignore_missing_imports = true +show_column_numbers = true +pretty = false +disallow_untyped_calls = true +disallow_untyped_defs = true + diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..22218ae --- /dev/null +++ b/requirements.txt @@ -0,0 +1,20 @@ +black==22.1.0 +click==8.0.4 +flake8==4.0.1 +isort==5.10.1 +mccabe==0.6.1 +mypy==0.931 +mypy-extensions==0.4.3 +numpy==1.22.2 +opencv-python==4.5.5.62 +pathspec==0.9.0 +platformdirs==2.5.1 +pycodestyle==2.8.0 +pydicom==2.2.2 +pyflakes==2.4.0 +pyproject-flake8==0.0.1a2 +python-gdcm==3.0.10.2 +toml==0.10.2 +tomli==2.0.1 +tqdm==4.63.0 +typing_extensions==4.1.1 \ No newline at end of file