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

[FEATURE] Configure settings without cloning repo #76

Open
jesse-wei opened this issue May 6, 2023 · 1 comment
Open

[FEATURE] Configure settings without cloning repo #76

jesse-wei opened this issue May 6, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@jesse-wei
Copy link
Collaborator

jesse-wei commented May 6, 2023

Settings are intended to be configured via the JSON config files gui_config.json and cli_config.json.

However, those files have to be in the directory NR is run from to be discovered. For now, this means cloning the repo.

When installing via pip and running from a Python terminal, those files may not exist. In that case, NR will grab the default gui_config.json and cli_config.json from the installed package, which the user can't easily find and edit.

Here's the code in constants.py that does this:

JSON_CLI_CONFIG_PATH: Path = Path("cli_config.json")
"""Settings that configure cli_settings.py."""
if not JSON_CLI_CONFIG_PATH.exists():
    # __name__ will get to the utils module
    # and cli_config.json is at root directory
    JSON_CLI_CONFIG_PATH = Path(
        pkg_resources.resource_filename(__name__, "../../cli_config.json")
    )

JSON_GUI_CONFIG_PATH: Path = Path("gui_config.json")
"""Settings that configure gui_settings.py."""
if not JSON_GUI_CONFIG_PATH.exists():
    # __name__ will get to the utils module
    # and gui_config.json is at root directory
    JSON_GUI_CONFIG_PATH = Path(
        pkg_resources.resource_filename(__name__, "../../gui_config.json")
    )

One solution would be to create an importable function (in NeuroRuler.__init__) that puts these files in cwd so that the user can edit and re-run GUI or CLI. Then these settings will persist as long as the user runs from that directory.

One could also create a function that simply modifies values in gui_settings.py or cli_settings.py.

@jesse-wei jesse-wei added the enhancement New feature or request label May 6, 2023
@jesse-wei
Copy link
Collaborator Author

File > Import MRI Settings accepts a NeuroRuler JSON in this format (the format that NR exports):

{
    "input_image_path": "/Users/jesse/Documents/GitHub/COMP523/NeuroRuler/data/150649_V06_t1w.nrrd",
    "output_contoured_slice_path": "/Users/jesse/Documents/GitHub/COMP523/NeuroRuler/output/150649_V06_t1w/150649_V06_t1w_contoured.png",
    "x_rotation": 0,
    "y_rotation": 0,
    "z_rotation": 0,
    "slice": 79,
    "smoothing_conductance": 3.0,
    "smoothing_iterations": 5,
    "smoothing_time_step": 0.0625,
    "filter_option": "Otsu",
    "upper_binary_threshold": 200.0,
    "lower_binary_threshold": 0.0,
    "circumference": 433.57236555037326
}

However, the import_json function could be improved to also accept the gui_config.json file.

Not sure what would have to happen after parsing the settings there. The app might need to restart?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant