sampsapursiainen / zeffiro_interface

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

Cannot import `multicompartment_head_project` #197

Closed mshavliuk closed 1 year ago

mshavliuk commented 1 year ago

Description

I can't import the multicompartment head project from this directory, even though it was possible recently

Steps to reproduce

Run via import example:

addpath scripts
zef_import_example

Gives me this error:

Check for incorrect argument data type or missing argument in call to function 'struct2cell'.

Error in zef_import_parcellation_colortable (line 39)
    parcellation_aux = {parcellation_aux{1:2}, struct2cell(parcellation_aux{3})};

Error in zef_import_segmentation (line 271)
        zef = zef_import_parcellation_colortable(zef,atlas_colortable_filename,compartment_tag,atlas_merge);

Error in zeffiro_interface (line 415)
        zef = zef_import_segmentation(zef);

Alternatively, when I try to import the same project manually, I get exactly the same error, although I can see that some parts of the project are successfully imported. See the screenshot below

Expected behavior

The project gets imported.

Screenshots

Screenshot 2023-05-06 at 17 56 07

Context

Name Value
Version 2241fdd zef_nse_sigma: fix indentations with Matlab's smart indent tool
OS MacOS
Shell N/A
mshavliuk commented 1 year ago

This issue is not applicable to the main_development_branch branch and was noticed only in 192-fs2zefsh-improvements

SeSodesa commented 1 year ago

It looks like the order of struct fields inside of the color table files generated by fs2zef.sh are different between the old multicompartment_head_project and the newer segmentations generated by fs2zef.m. Previously it was parcellation_aux{1} that contained the struct, but in the newer segmentations it is parcellation_aux{3} that contains it.

This is a bit strange since the Matlab function that saves the color table files, and which is called by fs2zef.m, is the same as before. It might also be that the segmentation in multicompartment_head_project was generated with an older version of FreeSurfer. With the new segmentations, the line that now causes errors works just fine, at least with s certain .nii file.

The sensible thing to do here would be to rewrite the entire import routine, such that it does not rely on the field order of the struct, returned by load("file.mat").

SeSodesa commented 1 year ago

@mshavliuk I added an order-agnostic way of loading the fields from the color table files generated by the function called by fs2zef.m to the HEAD of 192-fs2zefsh-improvements. I tested it with a newer segmentation and the older one in

scripts/scripts_for_importing/multicompartment_head_project

and they both seem to pass without errors. What still needs testing is the mesh generation, since it relies on the imported segmentation being correct. If it works with both newer and older segmentations, then the relevant branch can be merged to main_development_branch.

SeSodesa commented 1 year ago

It seems like at least a mesh can be generated with the given newer and older segmentations. I think #193 might be safe to merge at this point.

mshavliuk commented 1 year ago

It seems like at least a mesh can be generated with the given newer and older segmentations. I think #193 might be safe to merge at this point.

I will test it shortly and let you know if everything's ok