-
Notifications
You must be signed in to change notification settings - Fork 0
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
WIP: Remove string & object types to clean up the context #35
WIP: Remove string & object types to clean up the context #35
Conversation
For the attributes "noiseFWHMInUnits" and "noiseFWHMInVoxels" in the SearchSpaceMaskMap class whose IDs are : NIDM_0000157 and NIDM_0000159, the method is slightly different. In Protegé, they match with spm files which are deprecated and still appear in the file nidm-results.owl. It seems that alter the reading of the nidm files. Hence, I choose to remove those lines corresponding to the spm identifiers : from line 952 to 963 and from line 979 to 991 in nidm-results.owl. |
@natachaperez: thanks! It would be nice to better understand why this is happening though. Can you try and identify which line (or minimal subsets of lines) has to be removed from the owl file to obtain the behavior we want? |
@cmaumet I tried line by line and we have to remove these following lines to obtain the behavior we want :
|
@natachaperez: thanks a lot for those edits! For documentation purposes, can you add a comment explaining briefly what changes you introduced in the last set of commits and why? |
So I introduce those following lines (in bold) in create_nidmr_context.py:
These changes fix the problem encountered with the attributes "NoiseFWHMInUnits" and "FWHMInVoxels" without changing the owl file. Indeed, the issue was linked with the presence of the same json_key twice whereas a key must be unique in a dictionary. The idea was to change the json_key ( e.g. to delete the '_') after having completed the context. Then, we must ensure that none of deprecated labels remains in the context. |
The changes above in create_nidmr_context enable to gather the lines previously added: |
I added a check with the autopep8 command in order to be in line with the PEP8 convention for the python file create_nidmr_context and I remove the useless lines as comments. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @natachaperez!
Thanks for this pull request. I only have a few minor comments regarding remaining PEP8 formatting issue and creating one variable to make the code easier to read. Once this is updated, the pull request will be ready to merge.
RELPATH = os.path.dirname(os.path.abspath(__file__)) | ||
NIDMRESULTSPATH = os.path.dirname(RELPATH) | ||
NIDMPATH = os.path.join(NIDMRESULTSPATH, os.pardir) | ||
RELPATH = os.path.dirname(os.path.abspath(__file__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
RELPATH = os.path.dirname(os.path.abspath(__file__)) | |
RELPATH = os.path.dirname(os.path.abspath(__file__)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@natachaperez: this looks like a remaining PEP8 issue (there should be no space at end of line). Can you look for all those lines where a space was added and remove them? You have an overview of all the changes at: https://github.com/cmaumet/nidm/pull/35/files
NIDMRESULTSPATH = os.path.dirname(RELPATH) | ||
NIDMPATH = os.path.join(NIDMRESULTSPATH, os.pardir) | ||
RELPATH = os.path.dirname(os.path.abspath(__file__)) | ||
NIDMRESULTSPATH = os.path.dirname(RELPATH) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIDMRESULTSPATH = os.path.dirname(RELPATH) | |
NIDMRESULTSPATH = os.path.dirname(RELPATH) |
NIDMPATH = os.path.join(NIDMRESULTSPATH, os.pardir) | ||
RELPATH = os.path.dirname(os.path.abspath(__file__)) | ||
NIDMRESULTSPATH = os.path.dirname(RELPATH) | ||
NIDMPATH = os.path.join(NIDMRESULTSPATH, os.pardir) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
NIDMPATH = os.path.join(NIDMRESULTSPATH, os.pardir) | |
NIDMPATH = os.path.join(NIDMRESULTSPATH, os.pardir) |
if s in owl.ranges: | ||
context['@context'][json_key]['@id'] = str(s) | ||
context['@context'][json_key]['@type'] = next(iter(owl.ranges[s])) | ||
if 'http://www.w3.org/2001/XMLSchema#int' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#double' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#integer' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#positiveInteger' in next(iter(owl.ranges[s])) : |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To make the code easier to read, let's use a variable ranges
to store what's in next(iter(owl.ranges[s]))
.
if 'http://www.w3.org/2001/XMLSchema#int' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#double' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#integer' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#positiveInteger' in next(iter(owl.ranges[s])) : | |
ranges = next(iter(owl.ranges[s])) | |
if 'http://www.w3.org/2001/XMLSchema#int' in ranges or 'http://www.w3.org/2001/XMLSchema#double' in ranges or 'http://www.w3.org/2001/XMLSchema#integer' in ranges or 'http://www.w3.org/2001/XMLSchema#positiveInteger' in ranges: |
context['@context'][json_key]['@type'] = next(iter(owl.ranges[s])) | ||
if 'http://www.w3.org/2001/XMLSchema#int' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#double' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#integer' in next(iter(owl.ranges[s])) or 'http://www.w3.org/2001/XMLSchema#positiveInteger' in next(iter(owl.ranges[s])) : | ||
context['@context'][json_key]['@id'] = str(s) | ||
context['@context'][json_key]['@type'] = next(iter(owl.ranges[s])) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
context['@context'][json_key]['@type'] = next(iter(owl.ranges[s])) | |
context['@context'][json_key]['@type'] = ranges |
…of variable to simplify the code
@natachaperez: are you happy for me to merge now or you have remaining edits that you would like to commit? |
+1 for the merger @cmaumet |
(Now included in incf-nidash#479). |
I use the same process as for boolean type e.g. I added the line: ctxt = re.sub(r',\s*\n\s*"@type": "http://www.w3.org/2001/XMLSchema#string"', '', ctxt) in create_nidmr_context.py. Most of the issues are cleaned up, we have now the following structure : "attribute description": "@id" : " <> expect for two of them : NIDM_0000157 and NIDM_0000159.