phflot / flow_registration

Flow-Registration toolbox for 2P motion compensation
https://www.snnu.uni-saarland.de/flow-registration/
21 stars 2 forks source link

Suggestion for function set_path #1

Closed ehennestad closed 2 years ago

ehennestad commented 2 years ago

Hi Philipp,

I have a suggestion for the set_path function:

currentdir = fileparts( mfilename('fullpath') );

addpath(fullfile(currentdir, 'core'));
addpath(fullfile(currentdir, 'util'));
addpath(fullfile(currentdir, 'util', 'io'));

run(fullfile(currentdir, 'core', 'make.m'));

This way the set_path function can be run from any directory, or from a different script.

Best regards, Eivind

phflot commented 2 years ago

Hi Eivind, thank you for the suggestion. Just to better understand your usecase, do you have the basepath of the plugin in your path and then call set_path? I am currently using run() when I have to register the toolbox paths from wihin a script. Best wishes, Philipp

ehennestad commented 2 years ago

I have a simple "addonmanager" as part of Nansen, and users can choose to download flow_registration using this addonmanager. When the package is downloaded, I add it's directory to matlab's savepath, I call the set_path method.

However, I don't cd into the flow_registration directory, so the pwd command in set_path will fail. I was also thinking that hardcoding the '/' file separator might fail on Windows, but I haven't tested that.

ehennestad commented 2 years ago

1) I didn't realize that calling run() with a file path would be different than running a script directly, but if I use run(...) instead it works! 2) Tested on windows and file separator worked :)

phflot commented 2 years ago

run still works with your suggested solution and it is cleaner in case somebody runs set_path accidentally a second time so I have added the modifaction. Best wishes, Philipp