Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Binary file not shown.
Binary file modified code/livescripts/basicNeuroscienceDataset.mlx
Binary file not shown.
Binary file modified code/livescripts/crewMemberCollection.mlx
Binary file not shown.
1,167 changes: 701 additions & 466 deletions docs/tutorials/basicNeuroscienceDataset.html

Large diffs are not rendered by default.

1,234 changes: 728 additions & 506 deletions docs/tutorials/basicNeuroscienceDataset.md

Large diffs are not rendered by default.

340 changes: 193 additions & 147 deletions docs/tutorials/crewMemberCollection.html

Large diffs are not rendered by default.

320 changes: 182 additions & 138 deletions docs/tutorials/crewMemberCollection.md

Large diffs are not rendered by default.

90 changes: 21 additions & 69 deletions docs/tutorials/gettingStarted.html

Large diffs are not rendered by default.

102 changes: 17 additions & 85 deletions docs/tutorials/gettingStarted.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,38 +5,38 @@
disp( openminds.toolboxversion )
```

```TextOutput
Version 0.9.3
```matlabTextOutput
Version 0.9.7
```

If you have installed **openMINDS_MATLAB** and the above command does not work, most likely **openMINDS_MATLAB** is <u>not</u> added to MATLAB's [search path](https://se.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html).
If you have installed **openMINDS\_MATLAB** and the above command does not work, most likely **openMINDS\_MATLAB** is not added to MATLAB's [search path](https://se.mathworks.com/help/matlab/matlab_env/what-is-the-matlab-search-path.html).


If you opened this file in MATLAB Online from the GitHub Demo link, the following steps should add **openMINDS_MATLAB** to the search path:
If you opened this file in MATLAB Online from the GitHub Demo link, the following steps should add **openMINDS\_MATLAB** to the search path:


1) Open the <samp>code</samp> folder from the <samp>Files</samp> panel on the left sidebar.
1) Open the `code` folder from the `Files` panel on the left sidebar.


2) Open and run the <samp>startup.m</samp> file. Select "Add to Path" if prompted from a popup dialog.
2) Open and run the `startup.m` file. Select "Add to Path" if prompted from a popup dialog.


See also: [Crew Member Collection Tutorial](./livescripts/crewMemberCollection.mlx)

## Configure MATLAB's search path to use the latest model versions

Note: The following is only relevant if you have cloned or downloaded openMINDS_MATLAB from GitHub. If you installed the Matlab toolbox, you can skip this part.
Note: The following is only relevant if you have cloned or downloaded openMINDS\_MATLAB from GitHub. If you installed the Matlab toolbox, you can skip this part.


The openMINDS_MATLAB toolbox comes packaged with schema classes for all versions of the openMINDS models. Therefore is important to use the [<samp>openminds.startup</samp>](+openminds/startup.m) function to ensure that the search path only contains schema classes for a specific openMINDS version. Provide the version number as an input, i.e "latest", or "v2.0"
The openMINDS\_MATLAB toolbox comes packaged with schema classes for all versions of the openMINDS models. Therefore is important to use the [`openminds.startup`](+openminds/startup.m) function to ensure that the search path only contains schema classes for a specific openMINDS version. Provide the version number as an input, i.e "latest", or "v2.0"

```matlab
openminds.startup("latest") % Add schema classes for the latest version to the search path
```

```TextOutput
```matlabTextOutput
Initializing openMINDS_MATLAB...
Added schemas for version "latest" to path
Added classes for version "latest" of the openMINDS metadata model to the search path.
```
## Import schemas from the core model
```matlab
Expand All @@ -46,96 +46,28 @@ import openminds.core.*
```matlab
% Create a new demo subject
subject1 = Subject('species', 'musMusculus', 'biologicalSex', 'male', 'lookupLabel', 'demo_subject1');
disp(subject1)
```

```TextOutput
Subject (https://openminds.ebrains.eu/core/Subject) with properties:
biologicalSex: male (BiologicalSex)
internalIdentifier: ""
isPartOf: [None] (SubjectGroup)
lookupLabel: "demo_subject1"
species: Mus musculus (One of: Species, Strain)
studiedState: [None] (SubjectState)
Required Properties: species, studiedState
```
## Create a Subject State
```matlab
subjectState = openminds.core.SubjectState('lookupLabel', 'demo_state')
```matlabTextOutput
Error using openminds.core.research.Subject (line 73)
Invalid value for 'biologicalSex' argument. Value must be openminds.controlledterms.BiologicalSex or be convertible to openminds.controlledterms.BiologicalSex.
```

```TextOutput
subjectState =
SubjectState (https://openminds.ebrains.eu/core/SubjectState) with properties:
additionalRemarks: ""
age: [None] (One of: QuantitativeValue, QuantitativeValueRange)
ageCategory: [None] (AgeCategory)
attribute: [None] (SubjectAttribute)
descendedFrom: [None] (SubjectState)
handedness: [None] (Handedness)
internalIdentifier: ""
lookupLabel: "demo_state"
pathology: [None] (Any of: Disease, DiseaseModel)
relativeTimeIndication: [None] (One of: QuantitativeValue, QuantitativeValueRange)
weight: [None] (One of: QuantitativeValue, QuantitativeValueRange)
Required Properties: ageCategory
```matlab
disp(subject1)
```

## Create a Subject State
```matlab
subjectState = openminds.core.SubjectState('lookupLabel', 'demo_state')
% Add subject state to subject
subject1.studiedState = subjectState;
disp(subject1)
```

```TextOutput
Subject (https://openminds.ebrains.eu/core/Subject) with properties:
biologicalSex: male (BiologicalSex)
internalIdentifier: ""
isPartOf: [None] (SubjectGroup)
lookupLabel: "demo_subject1"
species: Mus musculus (One of: Species, Strain)
studiedState: demo_state (SubjectState)
Required Properties: species, studiedState
```

```matlab
% Update the value of the lookup label
subjectState.lookupLabel = "demo_subjectstate_pre_recording";

% Create a new subject state
subjectStatePost = openminds.core.SubjectState('lookupLabel', 'demo_subjectstate_post_recording')
```

```TextOutput
subjectStatePost =
SubjectState (https://openminds.ebrains.eu/core/SubjectState) with properties:
additionalRemarks: ""
age: [None] (One of: QuantitativeValue, QuantitativeValueRange)
ageCategory: [None] (AgeCategory)
attribute: [None] (SubjectAttribute)
descendedFrom: [None] (SubjectState)
handedness: [None] (Handedness)
internalIdentifier: ""
lookupLabel: "demo_subjectstate_post_recording"
pathology: [None] (Any of: Disease, DiseaseModel)
relativeTimeIndication: [None] (One of: QuantitativeValue, QuantitativeValueRange)
weight: [None] (One of: QuantitativeValue, QuantitativeValueRange)
Required Properties: ageCategory
```

```matlab
% Append the new subject state to the subject's studiedState property
subject1.studiedState(end+1) = subjectStatePost;
disp(subject1)
```

```TextOutput
Subject (https://openminds.ebrains.eu/core/Subject) with properties:
biologicalSex: male (BiologicalSex)
internalIdentifier: ""
isPartOf: [None] (SubjectGroup)
lookupLabel: "demo_subject1"
species: Mus musculus (One of: Species, Strain)
studiedState: [demo_subjectstate_pre_recording demo_subjectstate_post_recording] (SubjectState)
Required Properties: species, studiedState
```
3 changes: 3 additions & 0 deletions docs/exportTutorials.m → tools/+ommtools/exportTutorials.m
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ function exportTutorials()

for j = 1:numel(exportFormat)
export(sourcePath, strrep(targetPath, '.mlx', exportFormat(j)));
if exportFormat(j) == ".html"
postProcessLivescriptHtml(strrep(targetPath, '.mlx', exportFormat(j)))
end
end
end
end
69 changes: 69 additions & 0 deletions tools/+ommtools/private/postProcessLivescriptHtml.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
function postProcessLivescriptHtml(htmlFile)
%POSTPROCESSLIVESCRIPHTML Postprocess livescript HTMLs for improved online functionality
%
% This function performs the following actions:

%
% Syntax:
% postProcessLivescriptHtml(htmlFile)
%
% Input:
% htmlFile - (1,1) string: Path to the HTML file to process.
%
% Example:
% postProcessLivescriptHtml("example.html");

arguments
htmlFile (1,1) string {mustBeFile}
end

% Read the content of the HTML file
htmlContent = fileread(htmlFile);

% Remove unstable MATLAB-generated metadata from output wrappers.
htmlContent = stripOutputWrapperUidAttributes(htmlContent);
htmlContent = normalizeVariableEditorIds(htmlContent);

% Write the modified content back to the HTML file
try
fid = fopen(htmlFile, 'wt');
if fid == -1
error('Could not open the file for writing: %s', htmlFile);
end
fwrite(fid, htmlContent, 'char');
fclose(fid);
catch
error('Could not write to the file: %s', htmlFile);
end
end

function htmlContent = stripOutputWrapperUidAttributes(htmlContent)
expr = '(<div[^>]*class\s*=\s*"[^"]*eoOutputWrapper[^"]*")\s+uid="[^"]*"';
htmlContent = regexprep(htmlContent, expr, '$1');
end

function htmlContent = normalizeVariableEditorIds(htmlContent)
expr = 'variableeditor_(client_Document|views_SummaryBar|TableViewModel)_([0-9]+)';
tokens = regexp(htmlContent, expr, 'tokens');

if isempty(tokens)
return
end

originalSuffixes = cellfun(@(token) token{2}, tokens, 'UniformOutput', false);
uniqueSuffixes = unique(originalSuffixes, 'stable');

for i = 1:numel(uniqueSuffixes)
oldSuffix = uniqueSuffixes{i};
tempSuffix = sprintf('__omm_variableeditor_%d__', i);
htmlContent = regexprep(htmlContent, ...
['(variableeditor_(?:client_Document|views_SummaryBar|TableViewModel)_)' oldSuffix], ...
['$1' tempSuffix]);
end

for i = 1:numel(uniqueSuffixes)
tempSuffix = sprintf('__omm_variableeditor_%d__', i);
newSuffix = string(i);
htmlContent = strrep(htmlContent, tempSuffix, char(newSuffix));
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function org = organizationWithOneId()
% organizationWithOneId - Create a v4 Organization with one digital ID.

ror = openminds.core.RORID("identifier", "https://ror.org/01xtthb56");

org = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"fullName", "University of Oslo");
end
11 changes: 11 additions & 0 deletions tools/tests/oneOffs/+ommtest/+oneoffs/+v4/organizationWithTwoIds.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function org = organizationWithTwoIds()
% organizationWithTwoIds - Create a v4 Organization with two digital IDs.

ror = openminds.core.RORID("identifier", "https://ror.org/01xtthb56");
grid = openminds.core.GRIDID( ...
"identifier", "https://grid.ac/institutes/grid.5510.1");

org = openminds.core.Organization( ...
"digitalIdentifier", {ror, grid}, ...
"fullName", "University of Oslo");
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
function [person, affiliation] = personWithOneAffiliation()
% personWithOneAffiliation - Create a v4 Person with one Affiliation.

ror = openminds.core.RORID("identifier", "https://ror.org/02jx3x895");
org = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"fullName", "University College London");

affiliation = openminds.core.Affiliation("memberOf", org);

orcid = openminds.core.ORCID( ...
"identifier", "https://orcid.org/0000-0000-0000-0000");

contact = openminds.core.ContactInformation( ...
"email", "johndsmith@somewhere.org");

person = openminds.core.Person( ...
"familyName", "Smith", ...
"givenName", "John D.", ...
"alternateName", "js", ...
"affiliation", affiliation, ...
"digitalIdentifier", orcid, ...
"contactInformation", contact);
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
function [person, affiliations] = personWithTwoAffiliations()
% personWithTwoAffiliations - Create a v4 Person with two Affiliations.

ror = openminds.core.RORID("identifier", "https://ror.org/02jx3x895");
orgA = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"fullName", "University College London");

ror = openminds.core.RORID("identifier", "https://ror.org/01xtthb56");
orgB = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"fullName", "University of Oslo", ...
"shortName", "UiO");

affiliations = openminds.core.Affiliation("memberOf", orgA);
affiliations(2) = openminds.core.Affiliation("memberOf", orgB);

orcid = openminds.core.ORCID( ...
"identifier", "https://orcid.org/0000-0000-0000-0000");

contact = openminds.core.ContactInformation( ...
"email", "johndsmith@somewhere.org");

person = openminds.core.Person( ...
"familyName", "Smith", ...
"givenName", "John D.", ...
"affiliation", affiliations, ...
"digitalIdentifier", orcid, ...
"contactInformation", contact);
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
function org = organizationWithOneId()
% organizationWithOneId - Create a v5 Organization with one digital ID.

ror = openminds.core.RORID("identifier", "https://ror.org/01xtthb56");

org = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"name", "University of Oslo");
end
11 changes: 11 additions & 0 deletions tools/tests/oneOffs/+ommtest/+oneoffs/+v5/organizationWithTwoIds.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
function org = organizationWithTwoIds()
% organizationWithTwoIds - Create a v5 Organization with two digital IDs.

ror = openminds.core.RORID("identifier", "https://ror.org/01xtthb56");
rrid = openminds.core.RRID( ...
"identifier", "https://scicrunch.org/resolver/RRID:SCR_012345");

org = openminds.core.Organization( ...
"digitalIdentifier", {ror, rrid}, ...
"name", "University of Oslo");
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
function [person, affiliation] = personWithOneAffiliation()
% personWithOneAffiliation - Create a v5 Person and matching Affiliation.

ror = openminds.core.RORID("identifier", "https://ror.org/02jx3x895");
org = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"name", "University College London");

orcid = openminds.core.ORCID( ...
"identifier", "https://orcid.org/0000-0000-0000-0000");

contact = openminds.core.ContactInformation( ...
"email", "johndsmith@somewhere.org");

person = openminds.core.Person( ...
"familyName", "Smith", ...
"givenName", "John D.", ...
"preferredName", "John D. Smith", ...
"alternateName", "js", ...
"digitalIdentifier", orcid, ...
"contactInformation", contact);

affiliation = openminds.core.Affiliation( ...
"person", person, ...
"organization", org);
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
function [person, affiliations] = personWithTwoAffiliations()
% personWithTwoAffiliations - Create a v5 Person and two Affiliation records.

ror = openminds.core.RORID("identifier", "https://ror.org/02jx3x895");
orgA = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"name", "University College London");

ror = openminds.core.RORID("identifier", "https://ror.org/01xtthb56");
orgB = openminds.core.Organization( ...
"digitalIdentifier", ror, ...
"name", "University of Oslo", ...
"acronym", "UiO");

orcid = openminds.core.ORCID( ...
"identifier", "https://orcid.org/0000-0000-0000-0000");

contact = openminds.core.ContactInformation( ...
"email", "johndsmith@somewhere.org");

person = openminds.core.Person( ...
"familyName", "Smith", ...
"givenName", "John D.", ...
"preferredName", "John D. Smith", ...
"digitalIdentifier", orcid, ...
"contactInformation", contact);

affiliations = openminds.core.Affiliation( ...
"person", person, ...
"organization", orgA);
affiliations(2) = openminds.core.Affiliation( ...
"person", person, ...
"organization", orgB);
end
Loading
Loading