Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Json export: ':' in attribute names #40

Open
cmaumet opened this issue Feb 28, 2017 · 7 comments
Open

Json export: ':' in attribute names #40

cmaumet opened this issue Feb 28, 2017 · 7 comments

Comments

@cmaumet
Copy link
Member

cmaumet commented Feb 28, 2017

With @TomMaullin, we are looking at the json exports that SPM is generating and we were wondering if it would be possible to remove the ending ":" in the NIDM attribute names for the json export (but keep them in turtle). This would be similar to the behaviour of the Python rdflib.

The final ':' comes from this line: https://github.com/incf-nidash/nidmresults-spm/blob/master/exporter/spm_results_nidm.m#L1379.

@gllmflndn
Copy link
Contributor

I came across the same issue this morning and, yes, we should harmonise the serialisations. Can we look at this together later this week?
I also had to add a few calls to get_value.m and deal with bundles.
There are also differences in the way Derivations are encoded (for peaks to find out in which clusters they belong to).

@jbpoline
Copy link
Contributor

jbpoline commented Feb 28, 2017 via email

@cmaumet
Copy link
Member Author

cmaumet commented Mar 1, 2017

@gllmflndn: Yes! Working on this together this week would be great.

@jbpoline: I think this is something we could update in the SPM exporter. The final : are needed for alphanumeric ids in the turtle serialisation but are not necessary for the json serialisation.

@cmaumet
Copy link
Member Author

cmaumet commented Mar 14, 2017

Hi @gllmflndn. I have also encountered this issue when trying to create a json file similar to this one in which I had are a lot of MATLAB-"invalid" characters in the json keys (e.g. -, :, /,...).

Do you think we have a way around this or we will definitely have to limit ourselves to json keys that are valid MATLAB keys in order to be able to read/write those files in Matlab? This seems quite a big constraint compared to the json specification... I would love to hear your thoughts on this. Thank you!

@gllmflndn
Copy link
Contributor

gllmflndn commented Mar 16, 2017

Hello @cmaumet. To write such a JSON file, you have several options:

  • use containers.Map:
json = containers.Map('nidm_DesignMatrix/prov:atLocation','./DesignMatrix.csv');
spm_jsonwrite(json)
  • use hex ReplacementStyle option with changes I've just made to support it:
json = struct(matlab.lang.makeValidName('nidm_DesignMatrix/prov:atLocation','ReplacementStyle','hex'),'./DesignMatrix.csv');
spm_jsonwrite(json,struct('ReplacementStyle','hex'))
  • use GNU Octave:
json = struct('nidm_DesignMatrix/prov:atLocation','./DesignMatrix.csv');
spm_jsonwrite(json)

At the moment, the parsing of such files uses the underscore ReplacementStyle option: allowing hex is feasible but will be a bit more involved. Pull requests welcome at https://github.com/gllmflndn/JSONio

@cmaumet
Copy link
Member Author

cmaumet commented Mar 16, 2017

Thank you for all this @gllmflndn!

@gllmflndn
Copy link
Contributor

I tried to add the ReplacementStyle option in jsonread: gllmflndn/JSONio@755295e
A recompilation of MEX files is required.

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

No branches or pull requests

3 participants