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

Organizing the project #1

Closed
CsatiZoltan opened this issue Feb 4, 2020 · 5 comments
Closed

Organizing the project #1

CsatiZoltan opened this issue Feb 4, 2020 · 5 comments
Assignees
Labels
help wanted Extra attention is needed

Comments

@CsatiZoltan
Copy link
Owner

CsatiZoltan commented Feb 4, 2020

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

  • the directory structure corresponds to what is expected (or what is a good practice) in ImagePy
  • my Python functions and modules are completely separated from ImagePy, i.e. they can be usable without ImagePy being installed

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.

@CsatiZoltan CsatiZoltan added the help wanted Extra attention is needed label Feb 4, 2020
@CsatiZoltan CsatiZoltan pinned this issue Feb 4, 2020
@yxdragon
Copy link
Collaborator

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
Copy link
Owner Author

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
Copy link
Collaborator

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
Copy link
Owner Author

@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
Copy link
Owner Author

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

No branches or pull requests

2 participants