Skip to content

Conversation

@jeffersoncasimir
Copy link
Contributor

@jeffersoncasimir jeffersoncasimir commented Nov 15, 2024

Closes #9341

Brief summary of changes

Contains a new CSVParser class, extended by an InstrumentDataParser class.

A template file with the expected headers for the selected instrument can be downloaded from the new "Upload Instrument Data" panel's form in the Upload tab of the Instrument Manager module.

The uploaded .csv file will be saved and tracked in a new table called instrument_data_files.

The file's headers must match the selected instrument's expected headers.

For each row, an instrument is created using the NDB_BVL_Instrument::factory and is then saved to the database.

If an error is detected, the database transaction will be rolled back, and the list of errors will be returned to the user.

If the uploaded file exceeds a certain size (currently hard-coded to 512 MB), the task will be performed in the background as a new server_process_manager type called parse_instrument_data. This process runs the parse_instrument_data.php script. It is expected that the monitor_instrument_data.php script is run periodically to check the status of running tasks. When a task is done executing, the server_process_manager table is updated and the user who uploaded the file receives an email containing the "computed exit text".

  • Documentation updated

Testing instructions

  1. Select an instrument from the dropdown
  2. Download the headers template
  3. Manually add rows to the template and upload it
  4. Ensure it works as expected for files exceeding MAX_FILE_BYTES
  5. Ensure MriUploadServerProcess still works as expected

Screenshots:
Screenshot 2025-08-12 at 12 58 45 PM
Screenshot 2025-08-12 at 12 59 01 PM
Screenshot 2025-02-05 at 9 33 27 AM
Screenshot 2025-02-05 at 9 37 17 AM
Screenshot 2025-02-05 at 9 34 20 AM
Screenshot 2025-02-05 at 9 35 11 AM

Screenshot 2025-08-12 at 12 58 57 PM

New features since writing:

  • Create participants and sessions if they don't exist
    • Two different expected/downloadable templates
  • Return StudyID -> PSCID mapping when creating participants
  • REDCap functionality (upload DD. Converts to .LINST files w/ redcap{@}true in .meta)
  • Ability to bulk upload data for multiple instrument at once (mainly for REDCap, but works for all)

Still unresolved:

  • examiner is always uploader

@skarya22
Copy link
Contributor

skarya22 commented Nov 19, 2024

From Nov 19 LORIS call:

  • Move data upload to Browse instead of Upload
  • Should store the CSV somewhere that was uploaded
  • Change from saveValues to save so that there is validation
  • TODO: Discuss further about what the behaviour should be when data is not validated correctly. Don't upload anything, or upload all without errors

@jeffersoncasimir jeffersoncasimir force-pushed the 2024_10_28_instrument_data_parser branch from b50171d to 73f26b9 Compare February 3, 2025 22:45
@jeffersoncasimir jeffersoncasimir marked this pull request as ready for review February 5, 2025 14:40
@jeffersoncasimir jeffersoncasimir added this to the 27.0.0 milestone Feb 11, 2025
@jeffersoncasimir jeffersoncasimir force-pushed the 2024_10_28_instrument_data_parser branch from e334448 to dfecef0 Compare February 24, 2025 18:55
@jeffersoncasimir jeffersoncasimir added the Module: instrument_manager PR or issue related to instrument_manager module label Feb 28, 2025
@jeffersoncasimir jeffersoncasimir force-pushed the 2024_10_28_instrument_data_parser branch from 87fd447 to 1982dff Compare March 20, 2025 16:37
@jeffersoncasimir jeffersoncasimir force-pushed the 2024_10_28_instrument_data_parser branch from 578a57f to 9a9d471 Compare April 14, 2025 21:32
@github-actions github-actions bot added Language: SQL PR or issue that update SQL code RaisinBread PR or issue introducing/requiring improvements to the Raidinbread dataset Language: PHP PR or issue that update PHP code Language: Javascript PR or issue that update Javascript code Module: server_processes_manager PR or issue related to the server_processes_manger labels Apr 14, 2025
@jeffersoncasimir jeffersoncasimir force-pushed the 2024_10_28_instrument_data_parser branch from a34a08c to 46ee819 Compare June 19, 2025 22:49
@jeffersoncasimir jeffersoncasimir force-pushed the 2024_10_28_instrument_data_parser branch 2 times, most recently from fb3ad42 to ebf43b4 Compare August 11, 2025 16:37
@github-actions github-actions bot added Module: statistics PR or issue related to statistics module Module: issue_tracker PR or issue related to issue tracker module Module: dqt PR or issue related to (old) dqt module Module: acknowledgements PR or issue related to acknowledgements module Module: api_docs PR or issue related to api_docs module Module: battery_manager PR or issue related to battery_manager module Module: behavioural_qc PR or issue related behavioural_qc module Module: candidate_list PR or issue related to candidate_list module Module: candidate_parameters PR or issue related to candidate_parameters module Module: configuration PR or issue related to configuration module Module: conflict_resolver PR or issue related to conflict_resolver module Module: dashboard PR or issue related to dashboard module labels Aug 11, 2025
@jeffersoncasimir jeffersoncasimir removed Module: instrument_builder PR or issue related to instrument_builder module Module: instrument_list PR or issue related to instrument_list module Module: instruments PR or issue related to instruments module Module: login PR or issue related to login module Module: media PR or issue related to media module Module: module_manager PR or issue related to module_manager module Module: mri_violations PR or issue related to mri_violations module Module: new_profile PR or issue related to new_profile module Module: publication PR or issue related to the publication module Module: schedule_module PR or issue related to the schedule_manager module Module: survey_accounts PR or issue related to the survey_accounts module Module: user_accounts PR or issue related to the user_accounts module Module: dicom_archive PR or issue related to dicom_archive module Module: data_release PR or issue related to data_release module Module: dataquery PR or issue related to (new) dataquery module labels Aug 11, 2025
@jeffersoncasimir jeffersoncasimir marked this pull request as draft August 13, 2025 14:56
Comment on lines +305 to +307
if (is_null($dictionary)) {
return '';
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this a bug fix ?

If I got it correctly, it seems to be handling for cases where we have select / radio buttons with no option. The whole function is rather cryptic and lacking in comments IMO, and could benefit from a rewrite, but if this simple fix works, then that is also fine with me.

Anyway, if this is a bug fix as I said, could you split this into its own PR ?

@@ -0,0 +1,216 @@
<?php declare(strict_types=1);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(commenting code to allow thread discussion)

I only reviewed the REDCap-related parts of the PR, the whole part about parsing REDCap instrument CSV files and parsing them to LINST seems very similar to Regis' redcap2linst.php script, and I am worried this introduces significant duplication which will be hard to maintain and may display inconsistencies.

Also, this PR introduces a RedcapCSVParser.class.inc class in libraries, I would prefer that all the REDCap-related stuff, even libraries, go into the REDCap module, as to not bloat the shared libraries and keep the architecture more predictable and modular.

@MaximeBICMTL MaximeBICMTL added the Module: redcap PR or issue related to redcap module label Sep 3, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Language: Javascript PR or issue that update Javascript code Language: PHP PR or issue that update PHP code Language: SQL PR or issue that update SQL code Module: instrument_manager PR or issue related to instrument_manager module Module: redcap PR or issue related to redcap module Module: server_processes_manager PR or issue related to the server_processes_manger RaisinBread PR or issue introducing/requiring improvements to the Raidinbread dataset

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Generalized CSV importer for instrument data

3 participants