Skip to content

Commit

Permalink
Merge branch 'develop' into fli-iam#2084
Browse files Browse the repository at this point in the history
  • Loading branch information
youennmerel authored Apr 3, 2024
2 parents 72788c3 + b5fe6f4 commit 6da6b9d
Show file tree
Hide file tree
Showing 15 changed files with 226 additions and 80 deletions.
13 changes: 9 additions & 4 deletions docker-compose/database/4_add_studyStatistics_procedure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -10,25 +10,28 @@
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html


USE studies;

DROP PROCEDURE IF EXISTS getStudyStatistics;

delimiter //
CREATE PROCEDURE getStudyStatistics(IN studyId INT)
BEGIN
SELECT
SELECT DISTINCT
e.study_id AS study_id,
c.id AS center_id,
c.name AS center_name,
sc.subject_name_prefix AS center_prefix,
s.id AS subject_id,
s.name AS common_name,
e.id AS examination_id,
e.comment AS examination_comment,
e.examination_date AS examination_date,
da.id AS dataset_acquisition_id,
da.creation_date AS import_date,
d.id AS dataset_id,
dm.name AS dataset_name,
(CASE dm.dataset_modality_type WHEN 1 THEN 'Mr'
WHEN 2 THEN 'Meg'
WHEN 3 THEN 'Ct'
Expand All @@ -53,12 +56,14 @@ INNER JOIN
INNER JOIN
datasets.dataset_metadata dm ON d.updated_metadata_id = dm.id
INNER JOIN
datasets.subject_study ss ON d.subject_id = ss.subject_id
studies.subject_study ss ON d.subject_id = ss.subject_id
INNER JOIN
studies.subject s ON ss.subject_id = s.id
INNER JOIN
studies.study_center sc ON c.id = sc.center_id
WHERE e.study_id = studyId;
WHERE e.study_id = studyId
AND ss.study_id = studyId
AND sc.study_id = studyId;
END //

delimiter ;
delimiter ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
ALTER TABLE dataset ADD CONSTRAINT UK_qrxunikj09qwx7ci6fpopyyuh UNIQUE key (origin_metadata_id);
ALTER TABLE dataset ADD CONSTRAINT UK_q5hjffag30a00rysle2hyhyov UNIQUE key (updated_metadata_id);
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ DROP PROCEDURE IF EXISTS getStudyStatistics;
delimiter //
CREATE PROCEDURE getStudyStatistics(IN studyId INT)
BEGIN
SELECT
SELECT DISTINCT
e.study_id AS study_id,
c.id AS center_id,
c.name AS center_name,
Expand Down Expand Up @@ -54,12 +54,14 @@ INNER JOIN
INNER JOIN
datasets.dataset_metadata dm ON d.updated_metadata_id = dm.id
INNER JOIN
datasets.subject_study ss ON d.subject_id = ss.subject_id
studies.subject_study ss ON d.subject_id = ss.subject_id
INNER JOIN
studies.subject s ON ss.subject_id = s.id
INNER JOIN
studies.study_center sc ON c.id = sc.center_id
WHERE e.study_id = studyId;
WHERE e.study_id = studyId
AND ss.study_id = studyId
AND sc.study_id = studyId;
END //

delimiter ;
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
-- Shanoir NG - Import, manage and share neuroimaging data
-- Copyright (C) 2009-2019 Inria - https://www.inria.fr/
-- Contact us on https://project.inria.fr/shanoir/
--
-- This program is free software: you can redistribute it and/or modify
-- it under the terms of the GNU General Public License as published by
-- the Free Software Foundation, either version 3 of the License, or
-- (at your option) any later version.
--
-- You should have received a copy of the GNU General Public License
-- along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html


USE studies;

DROP PROCEDURE IF EXISTS getStudyStatistics;

delimiter //
CREATE PROCEDURE getStudyStatistics(IN studyId INT)
BEGIN
SELECT DISTINCT
e.study_id AS study_id,
c.id AS center_id,
c.name AS center_name,
sc.subject_name_prefix AS center_prefix,
s.id AS subject_id,
s.name AS common_name,
e.id AS examination_id,
e.comment AS examination_comment,
e.examination_date AS examination_date,
da.id AS dataset_acquisition_id,
da.creation_date AS import_date,
d.id AS dataset_id,
dm.name AS dataset_name,
(CASE dm.dataset_modality_type WHEN 1 THEN 'Mr'
WHEN 2 THEN 'Meg'
WHEN 3 THEN 'Ct'
WHEN 4 THEN 'Spect'
WHEN 5 THEN 'Pet'
WHEN 6 THEN 'Egg'
WHEN 7 THEN 'Generic'
WHEN 8 THEN 'Ieeg'
WHEN 9 THEN 'Micr'
WHEN 10 THEN 'Beh'
WHEN 11 THEN 'Nirs'
WHEN 12 THEN 'Xa' END) AS modality,
(CASE ss.quality_tag WHEN 1 THEN 'Valid' WHEN 2 THEN 'Warning' WHEN 3 THEN 'Error' END) AS quality
FROM
datasets.examination e
INNER JOIN
datasets.center c ON e.center_id = c.id
INNER JOIN
datasets.dataset_acquisition da ON e.id = da.examination_id
INNER JOIN
datasets.dataset d ON da.id = d.dataset_acquisition_id
INNER JOIN
datasets.dataset_metadata dm ON d.updated_metadata_id = dm.id
INNER JOIN
studies.subject_study ss ON d.subject_id = ss.subject_id
INNER JOIN
studies.subject s ON ss.subject_id = s.id
INNER JOIN
studies.study_center sc ON c.id = sc.center_id
WHERE e.study_id = studyId
AND ss.study_id = studyId
AND sc.study_id = studyId;
END //

delimiter ;
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
* Shanoir NG - Import, manage and share neuroimaging data
* Copyright (C) 2009-2019 Inria - https://www.inria.fr/
* Contact us on https://project.inria.fr/shanoir/
*
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see https://www.gnu.org/licenses/gpl-3.0.html
*/
Expand All @@ -27,7 +27,7 @@

/**
* MR dataset.
*
*
* @author msimon
*
*/
Expand Down Expand Up @@ -71,7 +71,7 @@ public class MrDataset extends Dataset {
/** Metadata updated by study card. */
@OneToOne(cascade = CascadeType.ALL)
private MrDatasetMetadata updatedMrMetadata;

/** Store temporarily the first image acquisition time until all images are processed*/
@Transient
private LocalDateTime firstImageAcquisitionTime;
Expand All @@ -82,14 +82,9 @@ public class MrDataset extends Dataset {

public MrDataset() {}

public MrDataset(Dataset d, MrProtocol mrpro) {
public MrDataset(Dataset d) {
super(d);
MrDataset mrDataset = (MrDataset) d;
MrProtocol mrp = new MrProtocol(mrpro, this);
this.diffusionGradients = new ArrayList<>(mrDataset.getDiffusionGradients().size());
for (DiffusionGradient dg : mrDataset.getDiffusionGradients()) {
this.diffusionGradients.add(new DiffusionGradient(dg, this, mrp));
}

this.echoTime = new ArrayList<>(mrDataset.getEchoTime().size());
for (EchoTime et : mrDataset.getEchoTime()) {
Expand All @@ -111,7 +106,7 @@ public MrDataset(Dataset d, MrProtocol mrpro) {
} else {
this.mrQualityProcedureType = null;
}
this.originMrMetadata = mrDataset.getOriginMrMetadata();
this.originMrMetadata = new MrDatasetMetadata(mrDataset.getOriginMrMetadata());

this.repetitionTime = new ArrayList<>(mrDataset.getRepetitionTime().size());
for (RepetitionTime rt : mrDataset.getRepetitionTime()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,6 @@ public Dataset(Dataset d) {
}

this.importedStudyId = d.getImportedStudyId();
this.studyId = d.getStudyId();
this.subjectId = d.getSubjectId();
this.downloadable = d.downloadable;
this.updatedMetadata = new DatasetMetadata(d.getUpdatedMetadata());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Object[] moveDataset(Dataset ds, Long studyId, Map<Long, Examination> exa
Dataset newDs = null;
if (ds.getDatasetAcquisition() != null && ds.getDatasetAcquisition().getId() != null) {
if ("Mr".equals(dsType)) {
newDs = new MrDataset(ds, ((MrDatasetAcquisition) ds.getDatasetAcquisition()).getMrProtocol());
newDs = new MrDataset(ds);
} else {
newDs = DatasetUtils.copyDatasetFromDataset(ds);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ public MrProtocol(MrProtocol mrPro, MrDataset mrDs) {
this.numberOfAverages = mrPro.getNumberOfAverages();
this.numberOfPhaseEncodingSteps = mrPro.getNumberOfPhaseEncodingSteps();
this.numberOfTemporalPositions = mrPro.getNumberOfTemporalPositions();
this.originMetadata = mrPro.getOriginMetadata();
this.originMetadata = new MrProtocolMetadata(mrPro.getOriginMetadata());
if (mrPro.getPatientPosition() != null) {
this.patientPosition = mrPro.getPatientPosition().getId();
} else {
Expand All @@ -241,7 +241,11 @@ public MrProtocol(MrProtocol mrPro, MrDataset mrDs) {
this.sliceThickness = mrPro.getSliceThickness();
this.temporalResolution = mrPro.getTemporalResolution();
this.magneticFieldStrength = mrPro.getMagneticFieldStrength();
this.updatedMetadata = mrPro.getUpdatedMetadata();
if (mrPro.getUpdatedMetadata() != null) {
this.updatedMetadata = new MrProtocolSCMetadata(mrPro.getUpdatedMetadata());
} else {
this.updatedMetadata = null;
}
}

/**
Expand Down
Loading

0 comments on commit 6da6b9d

Please sign in to comment.