Skip to content

Commit 63a7ab0

Browse files
authored
Fix uneven blood spreadsheets (#273)
* updated to handle uneven rows in input spreadsheet blood data * bump version
1 parent f8f4ca5 commit 63a7ab0

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

pypet2bids/pypet2bids/dcm2niix4pet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __init__(self, image_folder, destination_path=None, metadata_path=None,
206206
# replace the suffix in the destination path with '' if a non-nifti full file path is give
207207
if Path(destination_path).suffix:
208208
self.full_file_path_given = True
209-
self.destination_folder = destination_path.parent
209+
self.destination_folder = Path(destination_path).parent
210210
self.destination_path = Path(destination_path).with_suffix('')
211211

212212
if not self.full_file_path_given:

pypet2bids/pypet2bids/update_json_pet_file.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,15 @@ def get_metadata_from_spreadsheet(metadata_path: Union[str, Path], image_folder,
618618
except KeyError:
619619
pass
620620

621+
# even out the values in the blood tsv columns if they're different lengths by appending zeros to the end
622+
# of each column/list
623+
# determine the longest column
624+
longest_column = max([len(column) for column in spreadsheet_metadata['blood_tsv'].values()])
625+
# iterate over each column, determine how many zeros to append to the end of each column
626+
for column in spreadsheet_metadata['blood_tsv'].keys():
627+
zeros_to_append = longest_column - len(spreadsheet_metadata['blood_tsv'][column])
628+
spreadsheet_metadata['blood_tsv'][column] += [0] * zeros_to_append
629+
621630
# check for existing blood json values
622631
for column in blood_json_columns:
623632
try:

pypet2bids/pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[tool.poetry]
22
name = "pypet2bids"
3-
version = "1.3.4"
3+
version = "1.3.5"
44
description = "A python implementation of an ECAT to BIDS converter."
55
authors = ["anthony galassi <[email protected]>"]
66
license = "MIT"

0 commit comments

Comments
 (0)