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

T36 data format v2 #37

Open
wants to merge 67 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
67 commits
Select commit Hold shift + click to select a range
cf0bcbb
testing
Feb 16, 2022
1b41bda
wip
Feb 17, 2022
224139d
wip
Feb 17, 2022
ea05401
skeleton
Feb 17, 2022
59a3722
cleanup
Feb 17, 2022
a9d8c57
add a bone to the skeleton
Feb 17, 2022
c20f945
wip
Feb 17, 2022
fe93349
wip
Feb 17, 2022
8db607d
not necessary
Feb 17, 2022
3a978f0
wip
Feb 17, 2022
e7a611f
wip
Feb 22, 2022
234793d
wip
Feb 23, 2022
8dfdbfe
wip
Feb 25, 2022
cd39422
wip
Feb 25, 2022
89fb35c
wip
Mar 4, 2022
3f2f8be
wip
Mar 8, 2022
6d42f78
wip
Mar 8, 2022
de526c6
wip
Apr 1, 2022
46e43ae
wip
Apr 4, 2022
2fb93f2
wip
Apr 5, 2022
fdc2840
wip
Apr 5, 2022
7fa5d7c
wip
May 25, 2022
2b656c9
wip
May 25, 2022
44f8487
wip
May 25, 2022
7610ad0
wip
May 26, 2022
d6d453f
wip
May 26, 2022
aed8251
wip
May 31, 2022
d5baefd
wip
May 31, 2022
d412aa0
wip
May 31, 2022
a822d51
wip
May 31, 2022
edbbf97
wip
May 31, 2022
1751c9a
wip
May 31, 2022
1d261c6
wip
May 31, 2022
e5c4f62
wip
Jun 1, 2022
494ef22
wip
Jun 1, 2022
6fa030d
wip
Jun 1, 2022
e830f3e
wip
Jun 2, 2022
004ead7
wip
Jun 2, 2022
9ad8774
bug fixes and clarity improvements
Jun 2, 2022
4a93c73
reduce size
Jun 2, 2022
348bfbe
prior to review
Jun 2, 2022
bc59542
consistency
Jun 2, 2022
e2cff9a
after review with Bryan
Jun 2, 2022
ea8593e
wip
Jun 3, 2022
638fb90
wip
Jun 3, 2022
046d6f0
wip
Jun 3, 2022
095789f
wip
Jun 3, 2022
c20187d
wip
Jun 3, 2022
cf7782e
fix oa frame image
Jun 3, 2022
eb940b9
typo
Jun 3, 2022
bdab956
Merge pull request #3 from bryanc806/1-create-converter-for-imagio-pa…
amasmiller Jun 3, 2022
7151a3a
add comment
Jun 3, 2022
4b66043
Merge branch 'main' into 1-create-converter-for-imagio-pa-device-and-…
Jun 15, 2022
bffde85
Merge pull request #2 from amasmiller/1-create-converter-for-imagio-p…
amasmiller Jun 15, 2022
e04806d
add opencv requirement
jgroehl Aug 10, 2022
46d2bdd
adjust the enumeration after changing the indexing order
jgroehl Aug 10, 2022
b69b520
adjust ordering of elements to be in line with IPASC consensus docume…
jgroehl Aug 10, 2022
358e1d2
adjust FoV definition to fit the IPASC coordinate system definition
jgroehl Aug 12, 2022
b3fecb7
Merge pull request #5 from jgroehl/janek_testing
amasmiller Aug 25, 2022
118ae6c
update tests and examples
jgroehl Jun 26, 2023
f17d20e
include necessary changes for including wavelengths into the "measure…
jgroehl Jun 26, 2023
9ebd9a2
fix ubuntu and mac bugs
Jun 26, 2023
e07e3a1
Merge branch 'main' of https://github.com/amasmiller/PACFISH into ama…
jgroehl Jun 27, 2023
98f879c
add new metadata to testing utils
jgroehl Jun 27, 2023
bc40b08
Merge branch 'amasmiller-main' into T36-DataFormatV2
jgroehl Jun 27, 2023
0e08b04
Merge branch 'T36-DataFormatV2' of https://github.com/IPASC/PACFISH i…
jgroehl Jun 27, 2023
389f428
switch arguments in matlab adapter
jgroehl Jul 7, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ PACFISH API. We have examples for both `Python` and `MATLAB`.

## Use case: Implement a conversion adapter

impot pacfish as pf
import pacfish as pf

class DeviceSpecificAdapter(pf.BaseAdapter):

Expand Down
22 changes: 0 additions & 22 deletions examples/python/compare_python_matlab_hdf5_file.py

This file was deleted.

Binary file added examples/python/input/2017_12_11-10_54_55_0.lom
Binary file not shown.
Binary file not shown.
Binary file added examples/python/input/I0000001.dcm.lom
Binary file not shown.
51 changes: 51 additions & 0 deletions examples/python/read_imagio_file.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#
# This file reads an example Laser Optic Movie (LOM) produced by the Seno (https://senomedical.com/)
# Imagio System and produces an IPASC-compatible HDF5 file. In addition, if enabled, graphical
# representations of the data are written as .png files.
#

import os
import numpy as np
import cv2
import pathlib
from pacfish.api.adapters.Imagio_File_Converter import ImagioFileConverter
from pacfish import write_data
from pacfish import quality_check_pa_data

# input file is a Laser Optic Movie (LOM) from a scan of a phantom using the Seno Imagio system
# input_file = '../../examples/python/input/I0000001.dcm.lom' # Gen2 (4 OA frames, 1 US image, hair target)

# other examples
#input_file = '../../examples/python/input/2017_12_11-10_54_55_0.lom' # Gen1a (many OA frames, many US images, lesion)
input_file = '../../examples/python/input/20211102134837219776.dcm.lom' # Gen2 (many OA frames, many US images, hair target)

converter = ImagioFileConverter(input_file)

pa_data = converter.generate_pa_data()

quality_check_pa_data(pa_data, verbose=True, log_file_path="")

folder = "output/" + os.path.basename(input_file)
pathlib.Path(folder).mkdir(parents=True, exist_ok=True)

output_png = True # disable if needed
if (output_png):
timestamps = pa_data.get_measurement_time_stamps()
wavelengths = pa_data.get_acquisition_wavelengths()
for idx, oa_frame in enumerate(pa_data.binary_time_series_data[0, 0, :]):
iTick = str(int(timestamps[idx] * 1E3)) + "_msec"
wavelength = str(int(wavelengths[idx] * 1E9)) + "_nm"
file = folder + "/oa_" + str(iTick) + "_" + wavelength + ".png"
cv2.imwrite(file, (oa_frame+32768)/256) # conversion is to ensure image is written with 16-bit values
print(f"INFO: Wrote file '{file}' for OA frame")

for idx, us_image in enumerate(pa_data.meta_data_acquisition['ultrasound_image_data']):
iTick = str(int(pa_data.meta_data_acquisition['ultrasound_image_timestamps'][idx]*1E3)) + "_msec"
file = folder + "/us_" + str(iTick) + ".png"
cv2.imwrite(file, us_image)
print(f"INFO: Wrote file '{file}' for US frame")

file = folder + "/" + os.path.basename(input_file) + "_imagio_ipasc.hdf5"
write_data(file, pa_data)
print(f"INFO: Wrote file '{file}' with IPASC HDF5 data")

5 changes: 3 additions & 2 deletions examples/python/read_ipasc_hdf5_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
import numpy as np

name = "kwave_2Dsim_random_array_new"
FILE_PATH = r"..\..\data\ipasc_compatible_V1.hdf5"
FILE_PATH = r"..\..\data\sample_ipasc_kwave_2Dsim_circular_array.hdf5"
#FILE_PATH = f"C:/kWave-PACFISH-export/{name}.hdf5"
# FILE_PATH = "C:/standardised-image-reconstruction/15PPMPX__ZJQLvYSdWe5CxumvueVrizFy_ipasc.hdf5"

Expand All @@ -21,7 +21,8 @@
shape = np.shape(pa_data.binary_time_series_data)
plt.figure()
plt.title("Time Series Data")
plt.imshow(np.squeeze(pa_data.binary_time_series_data[:, :, 0].T))
plt.imshow(np.squeeze(pa_data.binary_time_series_data[:, :, 0].T), aspect=(pa_data.binary_time_series_data.shape[0]/
pa_data.binary_time_series_data.shape[1]))
plt.xlabel("Num detector elements")
plt.ylabel("Num time samples")
cb = plt.colorbar()
Expand Down
4 changes: 2 additions & 2 deletions examples/python/read_nrrd_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@

pa_data = converter.generate_pa_data()

quality_check_pa_data(pa_data, verbose=True, log_file_path="")
quality_check_pa_data(pa_data, verbose=True)

write_data("demodata_ipasc.hdf5", pa_data)

binary = np.rot90(pa_data.binary_time_series_data[:, 500:-2500, 0, 0], -1)
binary = np.rot90(pa_data.binary_time_series_data[:, 500:-2500, 0], -1)
binary = binary - np.min(binary) + 1
binary = np.log10(binary)
plt.imshow(binary, aspect=0.08, vmin=np.percentile(binary, 1), vmax=np.percentile(binary, 99))
Expand Down
7 changes: 4 additions & 3 deletions examples/python/visualise_zenodo_example_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@
#data_url = "https://zenodo.org/record/5938838/files/sample_ipasc_kwave_2Dsim_semicircular_array.hdf5"

# Downloading file
filename = download_file(data_url)
#filename = download_file(data_url)

# Loading file from disk as a pa_data instance
pa_data = pf.load_data(filename)
# "D:/PACFISH/examples/python/output/2017_12_11-10_54_55_0.lom/2017_12_11-10_54_55_0.lom_imagio_ipasc.hdf5"
pa_data = pf.load_data("D:/PACFISH/examples/python/output/20211102134837219776.dcm.lom/20211102134837219776.dcm.lom_imagio_ipasc.hdf5")

# perform completeness and consistency checking on the pa_data
pf.quality_check_pa_data(pa_data, verbose=True)
Expand All @@ -35,7 +36,7 @@
shape = np.shape(pa_data.binary_time_series_data)
plt.figure(figsize=(4.75, 4))
plt.title("Time Series Data")
plt.imshow(np.squeeze(pa_data.binary_time_series_data).T, aspect=shape[0]/shape[1])
plt.imshow(np.squeeze(pa_data.binary_time_series_data[:, :, 0]).T, aspect=shape[0]/shape[1])
plt.xlabel("Num detector elements")
plt.ylabel("Num time samples")
cb = plt.colorbar()
Expand Down
3 changes: 3 additions & 0 deletions pacfish/api/BaseAdapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ def __init__(self):
meta_data_device = self.generate_device_meta_data()
self.pa_data.meta_data_device = meta_data_device

# We hard-set the version number when exporting.
self.pa_data.meta_data_acquisition[MetadataAcquisitionTags.VERSION.tag] = "V2"


@abstractmethod
def generate_binary_data(self) -> np.ndarray:
Expand Down
Loading