From 2ebc9a55187dd8b0baabdec98aef311e3897be2e Mon Sep 17 00:00:00 2001 From: "ISDADS\\HLS501" Date: Tue, 7 May 2019 07:27:24 +0100 Subject: [PATCH 1/4] anonimised methods -[matlab and python] --- .../matlab/ChangeSubjectName-btk.m | 62 +++++++++++++++++++ .../python/anonymising-pyCGM2.py | 14 +++++ 2 files changed, 76 insertions(+) create mode 100644 Code/anonymising c3d/matlab/ChangeSubjectName-btk.m create mode 100644 Code/anonymising c3d/python/anonymising-pyCGM2.py diff --git a/Code/anonymising c3d/matlab/ChangeSubjectName-btk.m b/Code/anonymising c3d/matlab/ChangeSubjectName-btk.m new file mode 100644 index 0000000..9d45044 --- /dev/null +++ b/Code/anonymising c3d/matlab/ChangeSubjectName-btk.m @@ -0,0 +1,62 @@ +function ChangeSubjectName +% change the name of subject in C3D files associated with models, markers, +% events +% vsk file should have the same name of the new name of the subject. +DefaultName = '\\DEFAULT PATH'; % TO EDIT +[C3D_filename,C3D_path]=uigetfile({'*.C3D'},'Select C3D file',DefaultName,'MultiSelect','on'); +nbre_fichier = size(C3D_filename,2); + +f=findstr(C3D_path,'\'); +def=C3D_path(f(end-2)+1:f(end-1)-1); +subject = inputdlg('Name of the new subject','Name of the new subject',1,{def}); +subject=char(subject); + +for t=1:nbre_fichier + C3D_file=char(C3D_filename(t)); + + if nbre_fichier ==1 + C3D_file = C3D_filename; + end + acq= btkReadAcquisition(char([C3D_path C3D_file])); + METADATA = btkGetMetaData(acq); + I1=struct(); + I3=struct(); + info1=struct(); + info3=struct(); + B={}; + % change subject name in the metadata + if isfield(METADATA.children,'SUBJECTS')==1 + info1=METADATA.children.SUBJECTS.children.NAMES.info; + I1 = btkMetaDataInfo('Char', {subject}); + btkAppendMetaData(acq,'SUBJECTS','NAMES',I1); + info2=METADATA.children.POINT.children.ANGLES.info; + I2 = btkMetaDataInfo('Char', {subject}); + btkAppendMetaData(acq,'POINT','ANGLES',I2); + end + + % change subject name in the events + n_event=btkGetEventNumber(acq); + if isempty(n_event)==0 + if n_event>0 + for i=1:n_event + btkSetEventSubject(acq, i, subject); + end + end + end + + % change subject name in analysis + if isfield(METADATA.children,'ANALYSIS')==1 + info3=METADATA.children.ANALYSIS.children.SUBJECTS.info; + if info3.dims(2)>0 + for i=1:info3.dims(2) + B{i}=subject; + end + I3 = btkMetaDataInfo('Char', B'); + btkAppendMetaData(acq,'ANALYSIS','SUBJECTS',I3); + end + end + + btkWriteAcquisition(acq,(char([C3D_path C3D_file]))); + disp(['Write - ' char([C3D_path C3D_file])]); +end +disp('Change Name finished') diff --git a/Code/anonymising c3d/python/anonymising-pyCGM2.py b/Code/anonymising c3d/python/anonymising-pyCGM2.py new file mode 100644 index 0000000..278aaf4 --- /dev/null +++ b/Code/anonymising c3d/python/anonymising-pyCGM2.py @@ -0,0 +1,14 @@ +# -*- coding: utf-8 -*- + +import os +from pyCGM2.Tools import btkTools + + +if __name__ == "__main__": + + c3dFilename = "" + DATA_PATH = os.getcwd() + "//" + + btkAcq = btkTools.smartReader(DATA_PATH+c3dFilename) + btkAcqUn = btkTools.changeSubjectName(btkAcq,subjectName) + btkTools.smartWriter(btkAcqUn, DATA_PATH+c3dFilename[:-4]+"-Anonymised.c3d") From aacfb5d51d0393f5174c6337ba8c9839b7bfbec8 Mon Sep 17 00:00:00 2001 From: "ISDADS\\HLS501" Date: Tue, 7 May 2019 07:46:36 +0100 Subject: [PATCH 2/4] readme of anonymising-pyCGM2.py --- .../python/anonymising-pyCGM2.py | 2 +- .../python/anonymising-pyCGM2.readme | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 1 deletion(-) create mode 100644 Code/anonymising c3d/python/anonymising-pyCGM2.readme diff --git a/Code/anonymising c3d/python/anonymising-pyCGM2.py b/Code/anonymising c3d/python/anonymising-pyCGM2.py index 278aaf4..00e701a 100644 --- a/Code/anonymising c3d/python/anonymising-pyCGM2.py +++ b/Code/anonymising c3d/python/anonymising-pyCGM2.py @@ -6,7 +6,7 @@ if __name__ == "__main__": - c3dFilename = "" + c3dFilename = "TO EDIT" DATA_PATH = os.getcwd() + "//" btkAcq = btkTools.smartReader(DATA_PATH+c3dFilename) diff --git a/Code/anonymising c3d/python/anonymising-pyCGM2.readme b/Code/anonymising c3d/python/anonymising-pyCGM2.readme new file mode 100644 index 0000000..3448eb1 --- /dev/null +++ b/Code/anonymising c3d/python/anonymising-pyCGM2.readme @@ -0,0 +1,39 @@ +**DESCRIPTION** +change name of the subject into the c3d + +(@CarolineORLAUKeele : ready to sell your scripted USB stick on ebay :-) ) + +**SYNOPSIS** + +When you export a c3d, from Vicon Nexus for instance, the name of the subject is defined in different sections of the c3d. +This function allows to change the subject name everywhere and export a new c3d with *-anonymised" as suffix + + + +**AUTHOR** + +Fabien Leboeuf : University Salford (UK) + + + +**REQUIREMENT** + + * this function need installation of [pyCGM2](https://pycgm2.github.io) + * compatible python2.7 only + + +**CHANGELOG** + + * *[2018-05-07]* proposal to CMASUKI + + +**TODO** + + + +**HOW TO** + + 1. place the script "anonymising-pyCGM2.py" into your data folder + 2. open it with either your python editor pycharmm, spyder or a text editor like notepad + 3. edit you c3d filename (replace TOEDIT) + 4 run the python script ( double click on "anonymising-pyCGM2.py") if *python.exe* is associated with *.py file or use the run command of your python IDE) From da084561d3057002d611f02a7bcacadcf09d236b Mon Sep 17 00:00:00 2001 From: "ISDADS\\HLS501" Date: Fri, 10 May 2019 23:11:26 +0100 Subject: [PATCH 3/4] add readme to steph changeSubject Name function --- .../matlab/changeSubjectName-btk.readme | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 Code/anonymising c3d/matlab/changeSubjectName-btk.readme diff --git a/Code/anonymising c3d/matlab/changeSubjectName-btk.readme b/Code/anonymising c3d/matlab/changeSubjectName-btk.readme new file mode 100644 index 0000000..e5e6e36 --- /dev/null +++ b/Code/anonymising c3d/matlab/changeSubjectName-btk.readme @@ -0,0 +1,32 @@ +**DESCRIPTION** +change subject name of a several c3d files + +**SYNOPSIS** + + + +**AUTHOR** + +Stephane Armand : HUG - Geneva (SW) + + + +**REQUIREMENT** + + * BTK ( matlab) 0 + + + +**CHANGELOG** + + * *[2018-05-07]* proposal to CMASUKI + + +**TODO** + + + +**HOW TO** + + 1. Run the m file + 2. Select your c3d set i the dialog box From 7c0a91af6ecff9d1884c0d4b9ce285ca09eb463b Mon Sep 17 00:00:00 2001 From: "ISDADS\\HLS501" Date: Fri, 24 May 2019 14:12:47 +0100 Subject: [PATCH 4/4] code index update with link to rCGM2 : A R package for visualisation and statistcial processing of 3D gait data --- Code/CodeIndex.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Code/CodeIndex.md b/Code/CodeIndex.md index 13684e0..bbcb02b 100644 --- a/Code/CodeIndex.md +++ b/Code/CodeIndex.md @@ -1,8 +1,9 @@ # Code Index -A list of the code contributed by our community members. This is either hosted here on the CMAS open-code repository, or externally. +A list of the code contributed by our community members. This is either hosted here on the CMAS open-code repository, or externally. When you add a new entry, make sure you include a link to the code, the required software, and your name, so we know who to thank! :heart::clap: -- [Gait Profile Score & Movement Analysis Profile](https://github.com/cmasuki/open-code/tree/master/Code/Gait_profile_score) by [Neil Postans](https://github.com/npostans). +- [Gait Profile Score & Movement Analysis Profile](https://github.com/cmasuki/open-code/tree/master/Code/Gait_profile_score) by [Neil Postans](https://github.com/npostans). Needs Python 2.7 (32 bit version) & Vicon Nexus 2.x - [Local Dynamic Stability code (Rosensteins Algorithm)](https://github.com/SjoerdBruijn/LocalDynamicStability) by [Sjoerd Bruijn](https://github.com/SjoerdBruijn) Needs Matlab (any version) - [Code to read accelerometry data from a mobile phone via Matlab in realtime](https://github.com/SjoerdBruijn/StreamPhoneData) by [Sjoerd Bruijn](https://github.com/SjoerdBruijn) Needs Matlab (any version) +- [visualisation and statistical processing of 3D gait data with R](https://github.com/pyCGM2/rCGM2) bu [Fabien Leboeuf](https://github.com/pyCGM2/rCGM2) Needs Rstudio