Skip to content

Commit

Permalink
add activity level validation
Browse files Browse the repository at this point in the history
  • Loading branch information
Remi-Gau committed Jun 2, 2024
1 parent 1497124 commit a59b4f6
Show file tree
Hide file tree
Showing 11 changed files with 126 additions and 99 deletions.
5 changes: 1 addition & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,4 @@ remark: package.json
npx remark *.md docs/*.md docs/**/*.md --rc-path .remarkrc

package.json:
npm install `cat npm-requirements.txt`

serve_app:
cd reproschema-ui/src && npm install && npm run serve
npm install `cat npm-requirements.txt`
2 changes: 1 addition & 1 deletion cobidas_schema
Submodule cobidas_schema updated 96 files
+1 −1 schemas/neurovault/activities/experimental_design/experimental_design_schema.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/length_of_blocks.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/length_of_runs.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/length_of_trials.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/number_of_experimental_units.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/number_of_imaging_runs.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/optimization.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/optimization_method.jsonld
+1 −1 schemas/neurovault/activities/experimental_design/items/type_of_design.jsonld
+1 −1 schemas/neurovault/activities/group_inference/group_inference_schema.jsonld
+1 −1 schemas/neurovault/activities/group_inference/items/group_smoothness_fwhm.jsonld
+1 −1 schemas/neurovault/activities/group_inference/items/group_statistic_parameters.jsonld
+1 −1 schemas/neurovault/activities/group_inference/items/group_statistic_type.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/group_modeling_schema.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_estimation_type.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_inference_type.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_model_multilevel.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_model_type.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_modeling_software.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_repeated_measures.jsonld
+1 −1 schemas/neurovault/activities/group_modeling/items/group_repeated_measures_method.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/individual_subject_modeling_schema.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/autocorrelation_model.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/contrast_definition.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/contrast_definition_cogatlas.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/hemodynamic_response_function.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/high_pass_filter_method.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/intrasubject_estimation_type.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/intrasubject_model_type.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/intrasubject_modeling_software.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/orthogonalization_description.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/used_dispersion_derivatives.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/used_high_pass_filter.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/used_motion_regressors.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/used_orthogonalization.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/used_reaction_time_regressor.jsonld
+1 −1 schemas/neurovault/activities/individual_subject_modeling/items/used_temporal_derivatives.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/intersubject_registration_schema.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/coordinate_space.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/functional_coregistered_to_structural.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/functional_coregistration_method.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/interpolation_method.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/intersubject_registration_software.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/intersubject_transformation_type.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/nonlinear_transform_type.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/object_image_type.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/resampled_voxel_size.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/smoothing_fwhm.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/smoothing_type.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/target_resolution.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/target_template_image.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/transform_similarity_metric.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/used_intersubject_registration.jsonld
+1 −1 schemas/neurovault/activities/intersubject_registration/items/used_smoothing.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/EchoTime.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/FlipAngle.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/MagneticFieldStrength.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/Manufacturer.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/ManufacturersModelName.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/PulseSequenceType.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/RepetitionTime.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/SliceTiming.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/acquisition_orientation.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/field_of_view.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/matrix_size.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/parallel_imaging.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/skip_factor.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/items/slice_thickness.jsonld
+1 −1 schemas/neurovault/activities/mri_acquisition/mri_acquisition_schema.jsonld
+1 −1 schemas/neurovault/activities/participants/items/group_comparison.jsonld
+1 −1 schemas/neurovault/activities/participants/items/group_description.jsonld
+1 −1 schemas/neurovault/activities/participants/items/handedness.jsonld
+1 −1 schemas/neurovault/activities/participants/items/inclusion_exclusion_criteria.jsonld
+1 −1 schemas/neurovault/activities/participants/items/number_of_rejected_subjects.jsonld
+1 −1 schemas/neurovault/activities/participants/items/number_of_subjects.jsonld
+1 −1 schemas/neurovault/activities/participants/items/proportion_male_subjects.jsonld
+1 −1 schemas/neurovault/activities/participants/items/subject_age_max.jsonld
+1 −1 schemas/neurovault/activities/participants/items/subject_age_mean.jsonld
+1 −1 schemas/neurovault/activities/participants/items/subject_age_min.jsonld
+12 −2 schemas/neurovault/activities/participants/participants_schema.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/SoftwareName.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/SoftwareVersion.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/b0_unwarping_software.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/motion_correction_interpolation.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/motion_correction_metric.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/motion_correction_reference.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/motion_correction_software.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/order_of_preprocessing_operations.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/quality_control.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/slice_timing_correction_software.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/used_b0_unwarping.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/used_motion_correction.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/used_motion_susceptibiity_correction.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/items/used_slice_timing_correction.jsonld
+1 −1 schemas/neurovault/activities/preprocessing/preprocessing_schema.jsonld
+1 −1 schemas/neurovault/protocols/neurovault_schema.jsonld
4 changes: 4 additions & 0 deletions ecobidas/create_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ def create_schema(

item_info = get_item_info(this_item)

if "message" in item_info and item_info["message"]:
activity.messages.append(item_info["message"])

print_item_info(activity_idx, item_idx, item_info)

item = define_new_item(item_info)
Expand Down Expand Up @@ -138,6 +141,7 @@ def initialize_activity(items: pd.DataFrame, output_dir: str | Path) -> tuple[Ac
name=activity_name,
prefLabel=activity_pref_label,
output_dir=f"{output_dir}/activities/{activity_name}/",
messages = []
)

print_info("activity", activity_pref_label, activity.URI)
Expand Down
12 changes: 11 additions & 1 deletion ecobidas/inputs/data-dictionary.json
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,15 @@
"VariableName": "mri_type",
"Description": "Mention the type of MRI this item is applicable to.",
"RequirementLevel": "optional"
},
"validation": {
"VariableName": "validation",
"Description": "Extra validation to perform on the item value. For example, `item_1 > item_2, Item 1 must be less then item 2.` means that the alert `'Item 1 must be less then item 2.'` will be displayed if `item_1 > item_2`. Comma act as separator between the cvheck to perform and alert to display.",
"RequirementLevel": "optional"
},
"UUID": {
"VariableName": "UUID",
"Description": "Unique identifier of the item.",
"RequirementLevel": "optional"
}
}
}
174 changes: 87 additions & 87 deletions ecobidas/inputs/neurovault/neurovault.tsv

Large diffs are not rendered by default.

7 changes: 7 additions & 0 deletions ecobidas/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,12 @@ def get_item_info(this_item: dict) -> dict:

mandatory = get_mandatory(this_item)

message = None
if "validation" in this_item and this_item["validation"].any():
tokens = convert_to_str(this_item["validation"]).split(",")
if len(tokens) > 1:
message = {"message": tokens[1].strip(), "jsExpression": tokens[0].strip()}

return {
"name": item_name,
"pref_label": pref_label,
Expand All @@ -75,6 +81,7 @@ def get_item_info(this_item: dict) -> dict:
"visibility": visibility,
"mandatory": mandatory,
"sub_section": sub_section,
"message": message
}


Expand Down
2 changes: 1 addition & 1 deletion reproschema-py
10 changes: 8 additions & 2 deletions tests/data/activities/visibility/visibility_schema.jsonld
Original file line number Diff line number Diff line change
Expand Up @@ -151,5 +151,11 @@
"reproschema:AutoAdvance",
"reproschema:AllowExport"
]
}
}
},
"messages": [
{
"message": "Radio vis must be greater than Foo.",
"jsExpression": "multi_2_or_5 < radio_vis"
}
]
}
4 changes: 2 additions & 2 deletions tests/inputs/test.tsv
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
activity_order include activity activity_pref_label preamble item item_pref_label item_description item_order mandatory visibility skip question field_type choices
activity_order include activity activity_pref_label preamble item item_pref_label item_description item_order mandatory visibility skip question field_type choices validation
1 1 Activity 2 number of subjects number of subjects 1 1 1 1 Number of subjects entering into the analysis integer
2 1 Activity 3 same activity integer item integer item 1 1 1 1 This is an integer item integer
2 1 Activity 3 different preamble slider item slider item 2 1 1 1 This is a slider item slider 1 | 100 | 10
Expand All @@ -17,7 +17,7 @@ activity_order include activity activity_pref_label preamble item item_pref_labe
5 1 Visibility radio_vis 4 1 1 1 select one or several answer radio_multiple 1 | 2 | 3 | 4 | 5 | 6
5 1 Visibility multi_gt_5 5 1 radio_vis>5 1 should appear for answers greater than 5 text
5 1 Visibility multi_lt_2 6 1 radio_vis<=2 1 should appear for answers less than 2 text
5 1 Visibility multi_2_or_5 7 1 radio_vis == 2 OR radio_vis == 5 1 should appear for answers 2 or 5 text
5 1 Visibility multi_2_or_5 7 1 radio_vis == 2 OR radio_vis == 5 1 should appear for answers 2 or 5 text multi_2_or_5 < radio_vis, Radio vis must be greater than Foo.
5 1 Visibility select_boolean 8 1 1 1 select one answer select preset:boolean
5 1 Visibility select_boolean==1 9 1 select_boolean==1 1 this should only show if you selected ‘yes’ text
5 1 Visibility select_boolean==0 10 1 select_boolean==0 1 this should only show if you selected ‘no’ text
2 changes: 1 addition & 1 deletion tests/test_convert_to_schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ def data_path():
def test_create_schema(tmp_path):
this_schema = Path(__file__).parent / "inputs" / "test.tsv"

out_dir = tmp_path
out_dir = Path(__file__).parent / "outputs"
# out_dir = tmp_path

print("\n")

Expand Down
3 changes: 3 additions & 0 deletions tests/test_item.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,7 @@ def test_get_item_info():
"mandatory": True,
"description": "item name",
"sub_section": "",
"message": None
}

assert item_info == expected
Expand Down Expand Up @@ -126,6 +127,7 @@ def test_get_item_info_with_name():
"mandatory": True,
"description": "desc",
"sub_section": "",
"message": None
}

assert item_info == expected
Expand Down Expand Up @@ -158,6 +160,7 @@ def test_get_item_info_with_only_name():
"mandatory": True,
"description": "desc",
"sub_section": "",
"message": None
}

assert item_info == expected
Expand Down

0 comments on commit a59b4f6

Please sign in to comment.