Skip to content

Commit

Permalink
Merge pull request #29 from mad-lab-fau/28-clarify-number-of-biomarke…
Browse files Browse the repository at this point in the history
…r-samples-prompt

28 clarify number of biomarker samples prompt
  • Loading branch information
a-mosquito authored May 30, 2023
2 parents 223546a + 418327f commit aedd290
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 17 deletions.
2 changes: 1 addition & 1 deletion carwatch/labels/label_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ def _generate_label_tex(self, barcode_id: int):
# center text in label
label_head = "\\genericlabel\n\\begin{center}\n\\begin{tabular}"
label_foot = "\\end{tabular}\n\\end{center}\n\n"
if self.study.has_evening_sample and all([sample == self.study.num_samples - 1]):
if self.study.has_evening_sample and all([sample == self.study.num_samples]):
# if last sample of the day is evening sample, it is marked with "E"
sample_name = "E"
if self.add_name:
Expand Down
13 changes: 4 additions & 9 deletions carwatch/qr_codes/study_qr_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,23 +128,18 @@ def _save_qr_img(self, qr_img):
qr_img.save(img_location)

def _sanitize_distances(self, saliva_distances: Union[int, Sequence[int]]) -> Sequence[int]:
# required number of saliva distances
num_morning_samples = self.study.num_samples
if self.study.has_evening_sample:
# evening sample counts into total number of distances
num_morning_samples = num_morning_samples - 1
if isinstance(saliva_distances, int):
return [saliva_distances] * (num_morning_samples - 1)
return [saliva_distances] * (self.study.num_samples - 1)
if isinstance(saliva_distances, list):
# all elements are ints
if all(isinstance(dist, int) for dist in saliva_distances):
# length is correct
if len(saliva_distances) == num_morning_samples - 1:
if len(saliva_distances) == self.study.num_samples - 1:
return saliva_distances
raise ValueError(
f"Incorrect number of saliva distances provided! "
f"Needs to be {num_morning_samples - 1}, as "
f"{num_morning_samples} morning samples will be taken."
f"Needs to be {self.study.num_samples - 1}, as "
f"{self.study.num_samples} samples will be taken throughout the day."
)
raise ValueError("Invalid data detected in saliva distances! All values need to be integers!")
raise ValueError("Saliva distances data type is invalid! Needs to be int or list of ints.")
8 changes: 4 additions & 4 deletions carwatch/scripts/prepare_study.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@
@click.option(
"--num-samples",
required=True,
prompt="Number of biomarker samples [per day]",
prompt="Number of biomarker samples [during the day, WITHOUT evening sample]",
type=int,
help="The daily number of biomarker samples taken from every participant.",
help="The daily number of biomarker samples taken throughout the day from every participant. This number does not include the evening sample.",
)
@click.option(
"--sample_prefix",
Expand All @@ -117,9 +117,9 @@
)
@click.option(
"--has-evening-sample",
prompt="Evening sample taken?",
prompt="Additional evening sample taken?",
is_flag=True,
help="Whether a biomarker sample is taken in the evening.",
help="Whether an additional biomarker sample is taken in the evening.",
cls=NumericChoice,
chosen_number="study_type",
option_map=EVENING_OPTION,
Expand Down
9 changes: 6 additions & 3 deletions carwatch/utils/study.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ def __init__(
num_days: int
Number of days the study will be conducted
num_samples: int
*Total* number of biomarker samples per day (including a potential evening sample!)
Number of biomarker samples per day (*excluding* a potential evening sample!)
num_subjects: int, optional
Number of subjects in the study
subject_path: str or :class:`~pathlib.Path`, optional
Expand All @@ -46,7 +46,7 @@ def __init__(
subject_prefix: str, optional
Add prefix to participant number (e.g., "VP_")
has_evening_sample: bool, optional
Whether a biomarker sample in the evening is also collected, default is ``False``
Whether an *additional* biomarker sample in the evening is collected, default is ``False``
sample_prefix: str, optional
Abbreviation of the type of sample taken, default is ``'S'`` for 'Saliva'
start_sample_from_zero: bool, optional
Expand Down Expand Up @@ -180,4 +180,7 @@ def sample_indices(self):
list of sample indices
"""
return list(range(0, self.num_samples))
if self.has_evening_sample:
return list(range(0, self.num_samples + 1))
else:
return list(range(0, self.num_samples))

0 comments on commit aedd290

Please sign in to comment.