cwatson / brainGraph

Graph theory analysis of brain MRI data
173 stars 51 forks source link

User defined atlas not loadable by `set_brainGraph_attr` #4

Closed seantma closed 6 years ago

seantma commented 6 years ago

@cwatson I've followed the User Guide Section 2.4 on generating my own atlas and saving it to a .rda file.

However, when calling it from set_brainGraph_attr, the atlas data table is loaded by eval(parse(text=atlas)) where only predefined atlases could be loaded but not user defined atlases. Setting up working directory to point to the user's atlas setwd() didn't work as well. Seems like it needs to be in the NAMESPACE or environment() path.

Any suggestions on how to get around this? Thanks!

cwatson commented 6 years ago

Yes, it is necessary to have the atlas data.table already in your NAMESPACE; you can do this by loading the .rda file. This is somewhat tedious but I think is the simplest solution for users who want to use their own atlas. Try that out and let me know if it works.

If you already did load the .rda file, then it's possible you're using a slightly older version of brainGraph (but I fixed a couple issues with custom atlases for the latest version that's on Github).

seantma commented 6 years ago

@cwatson I've tried both loading my .rda file into NAMESPACE as well as just pointing to the atlas filename. Both had errors generated.

When loading in the '.rda' and assigning the data.table to atlas, the error occurred in set_brainGraph_attr::vertex-level attributes section, line 171: atlas.dt <- eval(parse(text=atlas)) where the actual content of my atlas data.table gets parsed as text and everything gets messed up.

For the latter error, it mentioned my atlas couldn't be found.

cwatson commented 6 years ago

When you load the .rda file, is the name of the data.table object equal to the character string stored in atlas?

e.g., if atlas <- 'customAtlas'

does customAtlas exist in the search path?

What happens if you type get(atlas) in your session?

seantma commented 6 years ago

@cwatson I think having a different name for the data.table object and the .rda was the culprit. After changing them to the same the issue goes away. This issue can be closed now.

You might want to update this into your User Guide, Section 2.4, to help guide user generated atlases.

In addition, in the same Compatible atlases section, you've mentioned for the atlas data.table structure, the index column (and presumably the name.full column) can be ignored. I took this into mind and neglected adding them into my atlas' data.table. Sure enough there was an error when later using set_brainGraph_attr().

cwatson commented 6 years ago

@seantma Thanks for reporting back. I will add that information to the User Guide.

What I really meant about the index column is that it is unimportant to the user; however, it is used by a couple of functions. I can add a check in those functions, as well, to be more informative in error messages.

The name.full column can actually be ignored.