CsatiZoltan / GrainSegmentation

Identification of individual grains in microscopic images
GNU General Public License v3.0
6 stars 3 forks source link

Organizing the project #1

Closed CsatiZoltan closed 4 years ago

CsatiZoltan commented 4 years ago

My project will consist of multiple functions. I read in the demo document how to organize them. What I want is the following:

I have the following directory structure in mind.

README.md
LICENSE
.gitignore
requirements.txt (so that ImagePy handles the dependencies)
data
 |--- samples (sample images to segment)
 |    |--- image1.png
 |    |--- ...
 |--- icons (icons related to the ImagePy GUI)
 |    |--- icon1.svg
 |    |--- ...
doc
 |--- ...
 |--- ...
src
 |--- grain_segmentation.py
 |--- ... (some other files used by grain_segmentation.py)
menus (a new menu will appear in ImagePy)
 |--- Grain-Segment (this will be the name of the new menu)
 |    |--- __init__.py
 |    |--- workflow_plgs.py (contains multiple classes to call the functions of grain_segmentation.py)
 |    |--- workflow.wf (Workflow file, invokes the GUI elements from workflow_plgs.py)
 |    |--- demos
 |    |    |--- __init__.py
 |    |    |--- demo1.mc (also uses grain_segmentation.py)
 |    |    |--- ...
tools (optional, similar structure as for menus)
widgets (optionalm similar structure as for menus)

The grain_segmentation.py file is a module containing a bunch of functions, responsible for the main steps of the segmentation process (reading image, filtering, initial segmentation, skeletonization, final segmentation, etc.). The functions in this module should not know anything about the GUI (ImagePy) and can be used in any Python project once the basic dependencies (numpy, scipy, scikit-image) are fulfilled.

To help experimenting with the parameters of the image processing functions residing in grain_segmentation.py and to perform some tasks manually, ImagePy is used -- its code being in the GUI/ directory.

yxdragon commented 4 years ago

it is a question of how to organize the model. there are three method

  1. if the function is short. you can define the function in the plugin file.
  2. there are several functions, you can write them in a file, and you can use form ..xxx to import.
  3. if your functions is a system, you can build a package, then use pip install -e to add the path, then you can import it anywhere.
CsatiZoltan commented 4 years ago

I will choose method 2. This will keep the code separated from ImagePy and I think this project won't grow large enough to bother with option 3. Can you comment on the structuring of the ImagePy part of the project (i.e. the organization within src/GUI/)?

yxdragon commented 4 years ago

in fact, there is nothing related to GUI. ImagePy separate gui as clean as possible (Tool, Table, Filter). except custom widget.

but plugin project must be in specific structure ,menus, tools, widgets must be placed in the root. For the ImagePy 's plugin manager could download it and extract it in imagepy->plugins folder. (not imagepy->menus->plugins). Then the engine would parse this folder like others.

So the structure should be:

README.md LICENSE .gitignore model: your algorithsm data: demo and test data menus (optional): Filter, Simple, Table, Markdown, Workflow, Macros are all in menus. |-- folder : If there is no folder in the menus, it would be created. (top menu) if it exists, the folder determin where it is places (suche as name the folder 'plugins', it would be a plugins's submenu) |-- folder or file ... tools (optional): Tool widgets (optional): Widget

seaice this is another demo.

CsatiZoltan commented 4 years ago

@yxdragon Can I keep the already existing src directory in place of model what you wrote? Can you revise the edited directory structure above?

CsatiZoltan commented 4 years ago

The current directory structure (commit 9443e60) works well (tested from within ImagePy by Plugins -> Install -> Install Plugins), so I close this issue.