Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated rules to set the default project, cohort #809

Merged
merged 4 commits into from
Mar 6, 2023

Conversation

laemtl
Copy link
Contributor

@laemtl laemtl commented Oct 19, 2022

Solves several problems:

  • Profile getSubjectIDs comments/documentation for $subjectID{'ProjectID'} updated
  • Candidate insert statement updated with RegistrationProjectID instead of ProjectID.
  • Adds new LORIS Configs: CreateVisit (replace the variable in the prod file), default_project and default_cohort (fallback to the variables in the prod file if not set). See createVisit/Project/Cohort imaging config Loris#8384
  • Updated rules to set the default project:
    • Value in the prod file
    • session ProjectID
    • candidate RegistrationProjectID
    • config default_project
    • throw an error
  • Updated rules to set the default cohort:
    • Value in the prod file
    • session CohortID
    • config default_cohort
    • ("UNKN", 0)

@@ -88,6 +91,7 @@ sub getSubjectIDs {
# ? 1 : 2;
# When createVisitLabel is set to 0, $subjectID{'SubprojectID'} is ignored.

$subjectID{'ProjectID'} = 1;
Copy link
Collaborator

@nicolasbrossard nicolasbrossard Oct 19, 2022

Choose a reason for hiding this comment

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

I am not sure I would give a default value to the ProjectID. I think it would be better to leave it undefined and have the MRI pipeline complain that if was not set instead of setting the project ID of the newly created candidate to 1 (which might not be the correct value). @cmadjar Can you weigh in on this?

The rest of the PR gets my approval.

Copy link
Collaborator

Choose a reason for hiding this comment

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

I agree with @nicolasbrossard. Since ProjectID can be NULL I would leave the default to be undef.

Copy link
Contributor Author

@laemtl laemtl Oct 27, 2022

Choose a reason for hiding this comment

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

Yeah I agree it's not a super safe change. I get confused by this change.
Since v24.0 session ProjectID cannot be null. createVisitLabel is set to 1 by default, so I suspect setting Project to undef will trigger an error when attempting to create a session . Is setting createVisitLabel to 0 by default a better option?

Copy link
Collaborator

Choose a reason for hiding this comment

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

I am more worried about the scanner candidate having to have a ProjectID than a phantom session since that could technically be in the PatientName the same way the site is specified. But creating a scanner candidate for a specific project seems a little odd. Maybe we could create a 'scanner' project?

@@ -79,6 +81,7 @@ sub getSubjectIDs {

$subjectID{'createVisitLabel'} = 0;

# $subjectID{'SubprojectID'} = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

here as well, I would put the default to be undef

# When createVisitLabel is set to 1, SubprojectID must also
# be set to the ID of the subproject that the newly created
# visit should have. Assuming for example that all patient
# names end with "_<mySubProjectID>", then we could write:
# ($subjectID{'SubprojectID'}) = $patientName =~ /_(\d+)$/;
# When createVisitLabel is set to 0, $subjectID{'SubprojectID'} is ignored.

# $subjectID{'ProjectID'} = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

here as well, I would put the default to be undef

@@ -51,13 +51,15 @@ sub getSubjectIDs {

$subjectID{'createVisitLabel'} = 1;

# $subjectID{'SubprojectID'} = 1;
Copy link
Collaborator

Choose a reason for hiding this comment

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

here as well, I would put the default to be undef

DoB => $subjectIDsref->{'PatientDoB'},
Sex => $sex,
RegistrationCenterID => $centerID,
RegistrationProjectID => $subjectIDsref->{'ProjectID'},
Copy link
Collaborator

Choose a reason for hiding this comment

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

Given that the default ProjectID would be undef, I wonder whether the if statement line 1758 should not be modified by !defined $subjectIDsref->{'ProjectID'} and $pscid eq 'scanner' since no ProjectID should be assigned to scanner candidates.

@laemtl thoughts?

Copy link
Contributor Author

@laemtl laemtl Oct 27, 2022

Choose a reason for hiding this comment

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

I believe the change here will not allow scanners to be registered without a ProjectID.

Copy link
Collaborator

Choose a reason for hiding this comment

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

oh noooo. Indeed. I thought RegistrationProjectID could be NULL. Not sure what to do cause like you mentioned, a scanner can belong to more than one Project... Let's add that to tomorrow's LORIS agenda and see what we can do.

@cmadjar
Copy link
Collaborator

cmadjar commented Nov 1, 2022

@laemtl Based on today's discussion at the LORIS call, the best approach to this might be to set the RegistrationProjectID of the scanner candidate to be created to the same RegistrationProjectID as the one used for the candidate being scanned (PatientName).

Then, when Phantom session are being inserted into LORIS, the session ProjectID will be dependent on the string in the PatientName (the project info will be in the PatientName the same way the site info is).

@cmadjar
Copy link
Collaborator

cmadjar commented Nov 1, 2022

I guess, the same way we have determinePSC called before determineScannerID in tarchive_validation.pl, minc_insertion.pl and tarchiveLoader.pl, there should be a determineProjectID based on the PatientName which will then be passed to determineScannerID function the same way it is passed the CenterID.

@laemtl @nicolasbrossard would that make sense to you?

@nicolasbrossard
Copy link
Collaborator

@cmadjar Makes sense to me.

@cmadjar
Copy link
Collaborator

cmadjar commented Jan 20, 2023

@laemtl ping on this one :)

@cmadjar cmadjar added this to the 25.0.0 milestone Feb 9, 2023
@laemtl laemtl requested a review from cmadjar February 19, 2023 08:49
@cmadjar
Copy link
Collaborator

cmadjar commented Mar 2, 2023

@laemtl I tested the PR with the new config in the config module but I get the following error:

ERROR: Cannot create candidate 966666/ROM999 as the profile file does not define a ProjectID for him/her.

Looking at the code, I realize that the config values from the Config module are not being fetched as far as I can tell. Maybe you did not push the latest version of the code?

Note to myself for upcoming testing once this PR is updated to resume testing: (test on ROM666_966666_V1 which does not exist in RB with default Project set to Challah and default Cohort set to Stale)

tarchiveLoader.pl -profile prod -uploadID 124 /data/demo/data/tarchive/DCM_2016-08-19_ImagingUpload-16-50-H_7N05.tar 

@@ -93,6 +93,9 @@ use constant BIDS_DATASET_AUTHORS => 'bids_dataset_authors';
use constant BIDS_ACKNOWLEDGMENTS_TEXT => 'bids_acknowledgments_text';
use constant BIDS_README_TEXT => 'bids_readme_text';
use constant BIDS_VALIDATOR_OPTIONS_TO_IGNORE => 'bids_validator_options_to_ignore';
use constant CREATE_CANDIDATES => 'createCandidates';
use constant CREATE_VISIT => 'createVisit';
use constant DEFAULT_COHORT => 'default_cohort';
Copy link
Collaborator

Choose a reason for hiding this comment

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

missing the following here:

Suggested change
use constant DEFAULT_COHORT => 'default_cohort';
use constant DEFAULT_COHORT => 'default_cohort';
use constant DEFAULT_PROJECT => 'default_project';

Which results in the following error:

Bareword "DEFAULT_PROJECT" not allowed while "strict subs" in use at /data/qpn/bin/mri/uploadNeuroDB/NeuroDB/objectBroker/ConfigOB.pm line 477.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, it was probably introduced by a merge conflict not properly resolved 😄

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@cmadjar I will retest to make sure something else was not broken

@laemtl laemtl force-pushed the ProjectID-fix branch 7 times, most recently from 070215b to 5f3f634 Compare March 6, 2023 08:06
@laemtl
Copy link
Contributor Author

laemtl commented Mar 6, 2023

@cmadjar Ready!

Copy link
Collaborator

@cmadjar cmadjar left a comment

Choose a reason for hiding this comment

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

LGTM

@cmadjar cmadjar merged commit f20a3df into aces:main Mar 6, 2023
zaliqarosli pushed a commit to zaliqarosli/Loris-MRI that referenced this pull request Mar 9, 2023
* ProjectID fix

* New Config CreateVisit, default_project and default_cohort

* Create getDefaultCohort and getDefaultProject in ConfigOB

* Documentation and updates
@laemtl laemtl changed the title ProjectID fix Updated rules to set the default project, cohort Jul 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants