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

Clean-up database scan type #1139

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

maximemulder
Copy link
Contributor

@maximemulder maximemulder commented Jun 26, 2024

Complementary PR of LORIS #9304

@maximemulder maximemulder changed the title Improve database scan type Clean-up database scan type Jun 26, 2024
@maximemulder
Copy link
Contributor Author

I am having some troubles testing this PR because my dev database config got changed recently, but this should work. According to the files changed, only the DICOM to MINC ingestion pipeline needs to be tested.

@maximemulder maximemulder marked this pull request as ready for review June 26, 2024 18:05
@cmadjar
Copy link
Collaborator

cmadjar commented Aug 1, 2024

@maximemulder there is a conflict in this PR. Could you rebase and let @nicolasbrossard and I when it is ready to test/review?

Thank you :)

@maximemulder maximemulder marked this pull request as draft September 13, 2024 14:39
@maximemulder maximemulder force-pushed the improve-database-scan-type branch 3 times, most recently from 22a00c3 to 5e8b460 Compare September 20, 2024 17:06
@maximemulder maximemulder marked this pull request as ready for review September 26, 2024 16:32
@cmadjar cmadjar added this to the 27.0 milestone Oct 4, 2024
@maximemulder maximemulder added the S-Large Size: Large. Pull requests that are large or complex and require a thorough review label Oct 4, 2024
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.

Tested following scripts:

  • delete script 🟢
  • minc_insertion.pl 🔴 see suggested code changes in functions scan_type_text_to_id and scan_type_id_to_text of MRI.pm
  • imaging_non_minc_insertion.pl 🟢
  • minc_to_bids_converter.pl 🔴 see suggested code change in function getFileList of tools/minc_to_bids_converter.pl
  • get_dicom_files.pl 🟢
  • run_defacing_script.pl 🔴 see suggested code change in function check_if_deface_files_already_in_db function of tools/run_defacing_script.pl
  • register_processed_data.pl 🟢
  • run_dicom_archive_loader.py 🟢

🟢 = test successful 🥳
🔴 = bugs found, see attached comments for the bug resolution.

@@ -650,9 +639,10 @@ sub scan_type_id_to_text {
my $mriScanTypeOB = NeuroDB::objectBroker::MriScanTypeOB->new(
db => $db
);

my $mriScanTypeRef = $mriScanTypeOB->get(0, { ID => $typeID });
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
my $mriScanTypeRef = $mriScanTypeOB->get(0, { ID => $typeID });
my $mriScanTypeRef = $mriScanTypeOB->get(0, { MriScanTypeID => $typeID });

@@ -676,7 +666,7 @@ sub scan_type_text_to_id {
db => $db
);
my $mriScanTypeRef = $mriScanTypeOB->get(
0, { Scan_type => $type }
0, { MriScanTypeName => $type }
);

return @$mriScanTypeRef ? $mriScanTypeRef->[0]->{'ID'} : undef;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
return @$mriScanTypeRef ? $mriScanTypeRef->[0]->{'ID'} : undef;
return @$mriScanTypeRef ? $mriScanTypeRef->[0]->{'MriScanTypeID'} : undef;

@@ -427,7 +427,7 @@ sub getFileList {
SELECT
f.FileID,
File,
AcquisitionProtocolID,
MriScanTypeID,
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
MriScanTypeID,
mst.MriScanTypeID,

Otherwise, get the following error:

DBD::mysql::st execute failed: Column 'MriScanTypeID' in field list is ambiguous at /data/preventAD/bin/mri/tools/minc_to_bids_converter.pl line 456.

@@ -439,10 +439,10 @@ sub check_if_deface_files_already_in_db {
# base query
my $query = "SELECT COUNT(*) "
. " FROM files f "
. " JOIN mri_scan_type mst ON (mst.ID=f.AcquisitionProtocolID) ";
. " JOIN mri_scan_type mst USING (mst.MriScanTypeID=f.MriScanTypeID) ";
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
. " JOIN mri_scan_type mst USING (mst.MriScanTypeID=f.MriScanTypeID) ";
. " JOIN mri_scan_type mst ON (mst.MriScanTypeID=f.MriScanTypeID) ";

otherwise, get the following error:

DBD::mysql::st execute failed: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '.MriScanTypeID=f.MriScanTypeID)  WHERE (mst.MriScanTypeName = 't2-defaced' OR ms' at line 1 at tools/run_defacing_script.pl line 451.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Caveat for Existing Projects Needs Work Before Merging Refactoring S-Large Size: Large. Pull requests that are large or complex and require a thorough review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants