Skip to content

Commit 94dc628

Browse files
authored
Merge pull request #356 from VisLab/develop
Many corrections to the remodeling tools documentation
2 parents 7b047e3 + 35b4048 commit 94dc628

File tree

2 files changed

+51
-42
lines changed

2 files changed

+51
-42
lines changed

docs/source/FileRemodelingTools.md

Lines changed: 46 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,7 @@ from the data file if the columns exist.
711711
"operation": "remove_columns",
712712
"description": "Remove unwanted columns prior to analysis",
713713
"parameters": {
714-
"remove_names": ["value", "sample"],
715-
"ignore_missing": true
714+
"remove_names": ["value", "sample"]
716715
}
717716
}
718717
]
@@ -829,7 +828,7 @@ based on column values.
829828
| ------------ | ---- | ----------- |
830829
| *column_name* | str | The name of the column to be factored.|
831830
| *factor_values* | list | Column values to be included as factors. |
832-
| *factor_names* | list| Column names for created factors. |
831+
| *factor_names* | list| (**Optional**) Column names for created factors. |
833832
```
834833

835834
If *column_name* is not a column in the data file, a `ValueError` is raised.
@@ -841,8 +840,8 @@ If a specified value is missing in a particular file, the corresponding factor c
841840
If *factor_names* is empty, the newly created columns are of the
842841
form *column_name.factor_value*.
843842
Otherwise, the newly created columns have names *factor_names*.
844-
If *factor_names* is not empty, then *factor_values* must also be specified and
845-
both lists must be of the same length.
843+
If *factor_names* is not empty, then *factor_values* must also be specified
844+
and both lists must be of the same length.
846845

847846
(factor-column-example-anchor)=
848847
#### Factor column example
@@ -906,17 +905,20 @@ The [**HED search guide**](./HedSearchGuide.md) tutorial discusses the HED searc
906905
| Parameter | Type | Description |
907906
| ------------ | ---- | ----------- |
908907
| *queries* | list | A list of HED query strings. |
909-
| *query_names* | list | A list of names for the resulting factor columns generated by the queries. |
910-
| *remove_types* | list | Structural HED tags to be removed (usually `Condition-variable` and `Task`). |
911-
| *expand_context* | bool | (Optional) Expand the context and remove `Onse` and`Offset` tags before the query. |
908+
| *query_names* | list | (**Optional**) A list of names for the factor columns generated by the queries. |
909+
| *remove_types* | list | (**Optional**) Structural HED tags to be removed (usually `Condition-variable` and `Task`). |
910+
| *expand_context* | bool | (**Optional**: default True) Expand the context and remove <br/>`Onset` and`Offset` tags before the query. |
912911
913912
```
914913
The *query_names* list, which must be empty or the same length as *queries*,
915914
contains the names of the factor columns produced by the search.
916915
If the *query_names* list is empty, the result columns are titled "query_1",
917916
"query_2", etc.
918917

919-
The *remove_types* and *expand_context* are not yet implemented, and hence ignored in the current release.
918+
Most of the time the *remove_types* should be set to `["Condition-variable", "Task"]` and the effects of
919+
the experimental design captured using the `factor_hed_types_op`.
920+
If *expand_context* is set to *false*, the additional context provided by `Onset`, `Offset`, and `Duration`
921+
is ignored.
920922

921923
(factor-hed-tags-example-anchor)=
922924
#### Factor HED tags example
@@ -936,7 +938,7 @@ The resulting factor columns are named *correct* and *incorrect*, respectively.
936938
"parameters": {
937939
"queries": ["correct-action", "incorrect-action"],
938940
"query_names": ["correct", "incorrect"],
939-
"remove_types": [],
941+
"remove_types": ["Condition-variable", "Task"],
940942
"expand_context": false
941943
}
942944
}]
@@ -986,8 +988,10 @@ For additional information on how to encode experimental designs using HED, see
986988
| Parameter | Type | Description |
987989
| ------------ | ---- | ----------- |
988990
| *type_tag* | str | HED tag used to find the factors (most commonly *Condition-variable*).|
989-
| *type_values* | list | Values to factor for the *type_tag*.<br>If empty, all values of that *type_tag* are used. |
991+
| *type_values* | list | (**Optional**) Values to factor for the *type_tag*.<br>If omitted, all values of that *type_tag* are used. |
990992
```
993+
The event context (as defined by onsets, offsets and durations) is always expanded and one-hot (0's and 1's)
994+
encoding is used for the factors.
991995

992996
(factor-hed-type-example-anchor)=
993997
#### Factor HED type example
@@ -1006,8 +1010,7 @@ applies and 0's otherwise.
10061010
"operation": "factor_hed_type",
10071011
"description": "Factor based on the sex of the images being presented.",
10081012
"parameters": {
1009-
"type_tag": "Condition-variable",
1010-
"type_values": []
1013+
"type_tag": "Condition-variable"
10111014
}
10121015
}]
10131016
```
@@ -1047,9 +1050,9 @@ duration updated to encompass the temporal extent of the merged events.
10471050
| ------------ | ---- | ----------- |
10481051
| *column_name* | str | The name of the column which is the basis of the merge.|
10491052
| *event_code* | str, int, float | The value in *column_name* that triggers the merge. |
1050-
| *match_columns* | list | Columns whose values must match to collapse events. |
10511053
| *set_durations* | bool | If true, set durations based on merged events. |
1052-
| *ignore_missing* | bool | If true, missing *column_name* or *match_columns* do not raise an error. |
1054+
| *ignore_missing* | bool | If true, missing *column_name* or *match_columns* do not raise an error. |
1055+
| *match_columns* | list | (**Optional**) Columns whose values must match to collapse events. |
10531056
```
10541057

10551058
The first of the group of rows (each representing an event) to be merged is called the anchor
@@ -1088,9 +1091,9 @@ have the same values to be merged into a single event.
10881091
"parameters": {
10891092
"column_name": "trial_type",
10901093
"event_code": "succesful_stop",
1091-
"match_columns": ["stop_signal_delay", "response_hand", "sex"],
10921094
"set_durations": true,
1093-
"ignore_missing": true
1095+
"ignore_missing": true,
1096+
"match_columns": ["stop_signal_delay", "response_hand", "sex"]
10941097
}
10951098
}]
10961099
```
@@ -1161,15 +1164,15 @@ Remapping can be used to convert the column containing these codes into one or m
11611164
| *destination_columns* | list | A list of *n* names of the destination columns for the map. |
11621165
| *map_list* | list | A list of mappings. Each element is a list of *m* source <br/>column values followed by *n* destination values.<br/> Mapping source values are treated as strings. |
11631166
| *ignore_missing* | bool | If false, source column values not in the map generate "n/a"<br/> destination values instead of errors. |
1164-
| *integer_sources* | list | [**Optional**] A list of source columns that are integers.<br/> The *integer_sources* must be a subset of *source_columns*. |
1167+
| *integer_sources* | list | (**Optional**) A list of source columns that are integers.<br/> The *integer_sources* must be a subset of *source_columns*. |
11651168
```
11661169
A column cannot be both a source and a destination,
11671170
and all source columns must be present in the data files.
11681171
New columns are created for destination columns that are missing from a data file.
11691172

11701173
The *remap_columns* operation only works for columns containing strings or integers,
11711174
as it is meant for remapping categorical codes.
1172-
You must specify the which source columns contain integers so that `n/a` values
1175+
You must specify which source columns contain integers so that `n/a` values
11731176
can be handled appropriately.
11741177

11751178
The *map_list* parameter specifies how each unique combination of values from the source
@@ -1490,6 +1493,7 @@ The results of executing the previous *reorder_columns* transformation on the
14901493

14911494
The *split_rows* operation
14921495
is often used to convert event files from trial-level encoding to event-level encoding.
1496+
This operation is meant only for tabular files that have `onset` and `duration` columns.
14931497

14941498
In **trial-level** encoding, all the events in a single trial
14951499
(usually some variation of the cue-stimulus-response-feedback-ready sequence)
@@ -1515,7 +1519,6 @@ In this case a trial consists of a sequence of multiple events.
15151519
15161520
```
15171521

1518-
15191522
The *split_rows* operation requires an *anchor_column*, which could be an existing
15201523
column or a new column to be appended to the data.
15211524
The purpose of the *anchor_column* is to hold the codes for the new events.
@@ -1651,7 +1654,7 @@ all summaries.
16511654
| ------------ | ---- | ----------- |
16521655
| *summary_name* | str | A unique name used to identify this summary.|
16531656
| *summary_filename* | str | A unique file basename to use for saving this summary. |
1654-
| *append_timecode* | bool | (Optional) If True, append a time code to filename.<br/>False is the default. |
1657+
| *append_timecode* | bool | (**Optional**: Default false) If true, append a time code to filename. |
16551658
```
16561659

16571660
(summarize-column-names-example-anchor)=
@@ -1730,11 +1733,11 @@ The following table lists the parameters required for using the summary.
17301733
| ------------ | ---- | ----------- |
17311734
| *summary_name* | str | A unique name used to identify this summary.|
17321735
| *summary_filename* | str | A unique file basename to use for saving this summary. |
1733-
| *skip_columns* | list | A list of column names to omit from the summary.|
1734-
| *value_columns* | list | A list of columns to omit the listing unique values. |
1735-
| *append_timecode* | bool | (Optional) If True, append a time code to filename.<br/>False is the default.|
1736-
| *max_categorical* | int | (Optional) If given, the text summary shows top *max_categorical* values.<br/>Otherwise the text summary displays all categorical values.|
1737-
| *values_per_line* | bool | (Optional) If given, the text summary displays this <br/>number of values per line (default is 5).|
1736+
| *append_timecode* | bool | (**Optional**: Default false) If True, append a time code to filename. |
1737+
| *max_categorical* | int | (**Optional**: Default 50) If given, the text summary shows top *max_categorical* values.<br/>Otherwise the text summary displays all categorical values.|
1738+
| *skip_columns* | list | (**Optional**) A list of column names to omit from the summary.|
1739+
| *value_columns* | list | (**Optional**) A list of columns to omit the listing unique values. |
1740+
| *values_per_line* | int | (**Optional**: Default 5) If given, the text summary displays this <br/>number of values per line (default is 5).|
17381741
17391742
```
17401743

@@ -1866,10 +1869,11 @@ The following table lists the parameters required for using the summary.
18661869
| ------------ | ---- | ----------- |
18671870
| *summary_name* | str | A unique name used to identify this summary.|
18681871
| *summary_filename* | str | A unique file basename to use for saving this summary. |
1869-
| *append_timecode* | bool | (Optional) If True, append a time code to filename.<br/>False is the default.|
1872+
| *append_timecode* | bool | (**Optional**: Default false) If true, append a time code to filename. |
18701873
```
18711874

1872-
The *summarize_definitions* is mainly meant for verifying consistency in unknown `Def-expand` tags. This comes up where you have an assembled dataset, but no longer have the definitions stored (or never created them to begin with).
1875+
The *summarize_definitions* is mainly meant for verifying consistency in unknown `Def-expand` tags.
1876+
This comes up where you have an assembled dataset, but no longer have the definitions stored (or never created them to begin with).
18731877

18741878

18751879
(summarize-definitions-example-anchor)=
@@ -2029,10 +2033,10 @@ The *summarize_hed_tags* operation has the two required parameters
20292033
| *summary_name* | str | A unique name used to identify this summary.|
20302034
| *summary_filename* | str | A unique file basename to use for saving this summary. |
20312035
| *tags* | dict | Dictionary with category title keys and tags in that category as values. |
2032-
| *append_timecode* | bool | (Optional) If True, append a time code to filename.<br/>False is the default.|
2033-
| *include_context* | bool | (Optional) If true, expand the event context to <br/>account for onsets and offsets. |
2034-
| *replace_defs* | bool | (Optional) If true, the `Def` tags are replaced with the<br/>contents of the definition (no `Def` or `Def-expand`). |
2035-
| *remove_types* | list | (Optional) A list of types (such as `Condition-variable` and `Task` to remove. |
2036+
| *append_timecode* | bool | (**Optional**: Default false) If true, append a time code to filename. |
2037+
| *include_context* | bool | (**Optional**: Default true) If true, expand the event context to <br/>account for onsets and offsets. |
2038+
| *replace_defs* | bool | (**Optional**: Default true) If true, the `Def` tags are replaced with the<br/>contents of the definition (no `Def` or `Def-expand`). |
2039+
| *remove_types* | list | (**Optional**) A list of types such as `Condition-variable` and `Task` to remove. |
20362040
```
20372041

20382042
The *tags* dictionary has keys that specify how the user wishes the tags
@@ -2159,7 +2163,7 @@ This summary provides useful information about experimental design.
21592163
| *summary_name* | str | A unique name used to identify this summary.|
21602164
| *summary_filename* | str | A unique file basename to use for saving this summary. |
21612165
| *type_tag* | str | Tag to produce a summary for (most often *condition-variable*).|
2162-
| *append_timecode* | bool | (Optional) If True, append a time code to filename.<br/>False is the default.|
2166+
| *append_timecode* | bool | (**Optional**: Default false) If true, append a time code to filename.|
21632167
```
21642168
In addition to the two standard parameters (*summary_name* and *summary_filename*),
21652169
the *type_tag* parameter is required.
@@ -2251,8 +2255,8 @@ If *check_for_warnings* is false, the summary will not report warnings.
22512255
| ------------ | ---- | ----------- |
22522256
| *summary_name* | str | A unique name used to identify this summary.|
22532257
| *summary_filename* | str | A unique file basename to use for saving this summary. |
2254-
| *append_timecode* | bool | (Optional) If True, append a time code to filename.<br/>False is the default.|
2255-
| *check_for_warnings* | bool | (Optional) If true, warnings are reported in addition to errors.<br/>False is the default.|
2258+
| *append_timecode* | bool | (**Optional**: Default false) If true, append a time code to filename. |
2259+
| *check_for_warnings* | bool | (**Optional**: Default false) If true, warnings are reported in addition to errors. |
22562260
```
22572261
The *summarize_hed_validation* is a HED operation and the calling program must provide a HED schema version
22582262
and usually a JSON sidecar containing the HED annotations.
@@ -2622,13 +2626,13 @@ since the names specified in the first parameter are meant to represent the quer
26222626
The check only takes place if `query_names` exists, since naming is handled automatically otherwise.
26232627

26242628
```python
2625-
@staticmethod
2626-
def validate_input_data(parameters):
2627-
errors = []
2628-
if parameters.get("query_names", False):
2629-
if len(parameters.get("query_names")) != len(parameters.get("queries")):
2630-
errors.append("The list in query_names, in the factor_hed_tags operation, should have the same number of items as queries.")
2631-
return errors
2629+
@staticmethod
2630+
def validate_input_data(parameters):
2631+
errors = []
2632+
if parameters.get("query_names", False):
2633+
if len(parameters.get("query_names")) != len(parameters.get("queries")):
2634+
errors.append("The list in query_names, in the factor_hed_tags operation, should have the same number of items as queries.")
2635+
return errors
26322636
```
26332637

26342638

docs/source/HedMatlabTools.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -595,10 +595,15 @@ Python may be installed in your user space or in system space for all users.
595595
- You may want to add the location of the Python executable to your PATH.
596596
(Most installers give you that option as part of the installation.)
597597

598+
#### Installing in a virtual environment
598599

600+
https://www.mathworks.com/support/search.html/answers/1750425-python-virtual-environments-with-python-interface.html?fq%5B%5D=asset_type_name:answer&page=1
599601
(step-3-connect-python-to-matlab-anchor)=
600602
#### Step 3: Connect Python to Matlab
601603

604+
605+
C:\Users\username\AppData\Local\Programs\Python\python -m venv C:\Users\username\py38
606+
602607
Setting the Python version uses the MATLAB `pyenv` function with the `'Version'` argument
603608
as illustrated by the following example.
604609

0 commit comments

Comments
 (0)