sampsapursiainen / zeffiro_interface

Interface for using finite elements in inverse problems with complex domains
GNU General Public License v3.0
23 stars 15 forks source link

Scripts related to different studies cannot be run effortlessly from the project root folder #244

Closed SeSodesa closed 10 months ago

SeSodesa commented 11 months ago

Description

Currently, if one wishes to run scripts related to specific studies done with Zeffiro, one has to jump through unnecessary hoops to even start a computation. This is because

  1. the scripts/ and m/ folders are not automatically in the Matlab path and
  2. the Zeffiro startup script m/zef_start_config.m errors out, if all submodules (which are most probably not even related to the study) are not installed.

Ideally, one should simply be able to start up a computation by typing a path to the needed function.

Steps to reproduce

  1. Navigate to the Zeffiro Interface installation folder and
  2. attempt to start a study-related computation from the Matlab command line, by calling a main function related to a specific study, such as [stats, L] = inverse_sensitivity_fn(args...), without manually doing any modifications to the Matlab PATH or Zeffiro source code.

Expected behavior

The computation should start and finish without errors, as long as a user has provided arguments that conform to the pre-conditions of the given main function.

Error messages

Instead of screenshots, here is a description of events that occur, when trying to run a study-related function:

>> cd zeffiro_interface/

>> [stats, L] = inverse_sensitivity_fn("data/article_1_brain_10kL_d0.5mm.mat", "Dipole Scan", 1, -30, "L2", acceptable_source_depth=0.5, optimization_system_type="pbo", lead_field_filter_quantile=1, use_gpu=true, build_lead_field=false, build_mesh=false);
Unrecognized function or variable 'inverse_sensitivity_fn'.

>> addpath(genpath("."))
>> [stats, L] = inverse_sensitivity_fn("data/article_1_brain_10kL_d0.5mm.mat", "Dipole Scan", 1, -30, "L2", acceptable_source_depth=0.5, optimization_system_type="pbo", lead_field_filter_quantile=1, use_gpu=true, build_lead_field=false, build_mesh=false);
Error using evalc
Unrecognized function or variable 'ft_defaults'.

Error in zef_start_config (line 7)
if isequal(zef.zeffiro_restart, 0), evalc('ft_defaults'); end

Error in zeffiro_interface (line 285)
    zef_start_config;

Error in inverse_sensitivity_fn (line 159)
    project_struct = zeffiro_interface( ...

Context

Name Value
Version bf185da Add files via upload
OS Any and all
Shell Any and all

This could be fixed at least partially by making a +studies/+study_name/ folder for each study. Because this would make the folders packages from Matlab's point of view, one could start a study-related computation simply by typing

results = studies.study_name.main(args...) ;

into the Matlab command prompt. The m/ folder would also need to be added to the path somehow, but a function studies.init_paths or similar could be provided for any study-related main functions, which would do the necessary path additions.

This is if we do not wish to turn all Zeffiro folders into Matlab packages, which would be the ideal solution. It would simply take quite a bit of typing.

SeSodesa commented 10 months ago

Closed by #248.