Skip to content

Rename folder matlab_tools -> +simnibsMATLAB#607

Draft
SeSodesa wants to merge 17 commits intosimnibs:masterfrom
SeSodesa:dev/matlab/matlab-tools-into-matlab-namespace
Draft

Rename folder matlab_tools -> +simnibsMATLAB#607
SeSodesa wants to merge 17 commits intosimnibs:masterfrom
SeSodesa:dev/matlab/matlab-tools-into-matlab-namespace

Conversation

@SeSodesa
Copy link

@SeSodesa SeSodesa commented Nov 11, 2025

This turns the folder matlab_tools into a MATLAB namespace called simnibsMATLAB. In the code itself, function, script and class constructor calls are fully qualified for things to work:

output = simnibsMATLAB.subNameSpace.someFunction(inputs) ;

This is if the function is in the location +simnibsMATLAB/+subNameSpace/someFunction.m.

TODO:

  • Rename top-level folder from matlab_tools to +simnibsMATLAB.
  • Fully qualify all function, class constructor and script calls in the contained MATLAB code.
  • The above point requires slightly modifying the legacy folder structure of the +simnibsMATLAB/@gifti class folder, as the folder does not actually contain a proper class definition using the classdef keyword in the file gifti.m, but only functions. See instructions here: https://www.mathworks.com/help/matlab/matlab_oop/organizing-classes-in-folders.html.
  • The constructor of the gifti class is also problematic, as the call(s) to this = class(this,'simnibsMATLAB.gifti') causes a redefinition of the class object on the fly, resulting in an error. The class should have clearly defined properties, some of which should be set as empty values of their respective types if not needed.
  • More stuff?

Closes #606.

NOTE: when reviewing the changes, turn off whitespace diffs, because my editor is set to remove trailing whitespace and such unneeded things from all code files.

This turns the folder into a namespace called simnibsMATLAB. Since the
actual MATLAB code in this renamed folder was not modified yet, some
functions and scripts might be broken after this change. Functions,
scripts and classes will need to be fully qualified for things to work:

    output = simnibsMATLAB.subNameSpace.somFunction(inputs) ;

This is if the function is in the folder +simnibsMATLAB/+subNameSpace/.
…ction calls

Also remove extra whitespace from end of file, just because my editor is
configured to do that...
…on calls

Also automatic whitespace removal from end of file and lines.
@SeSodesa SeSodesa changed the title [broken] Rename folder matlab_tools -> +simnibsMATLAB Rename folder matlab_tools -> +simnibsMATLAB Nov 11, 2025
Again, unnecessary whitespace was also automatically removed, so check
the Git diffs with --ignore-all-space flag set.
…on calls

Also unnecessary whitespace removal.
Also superfluous whitespace removal.
This is to make it compatible with MATLAB's namespaces.

Added properties with beginnings of MATLAB property validation such that
the code generates an empty gifti object when the constructor is given
no arguments. However, it is unclear how to test this properly.

Ispecially interesting is the struct branch of the constructor, where
the given struct contains the fields 'metadata', 'label' and 'data'.
It seems that the original behaviour would have resulted in infinite
recursion (without testing). Now the object is just returned as-is.

You will want to disable whitespace diffs when reviewing this one.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support MATLAB namespaces in SimNIBS code

1 participant

Comments