Repository navigation
Review of the first version before publication - #1
danieleTrimarchi wants to merge 156 commits into
Conversation
|
|
||
| class Dim6: | ||
| class Dim6Intent(IntEnum): | ||
| ClutterFiltering = (0,) |
There was a problem hiding this comment.
Why (0,) instead of : 0 ?
Same question for the following values, as well as the values in clutterFilterType
There was a problem hiding this comment.
Scan.py is doing too much (1081 lines, one god class).
load_scan_hdf5, matchAcquisitionMode, canBeConsolidated, fill_default, and load_scan_binary are all long, deeply-nested, side-effect-heavy methods that read from a file/HDF5 group and mutate self.
canBeConsolidated in particular is a bad name for what it does — it mutates self.voxels, self.measuredTimes, self.probe.probeType as a side effect. That's a correctness trap waiting for a future maintainer who calls it twice or assumes it's pure.
There was a problem hiding this comment.
outdated, changed in recent versions
There was a problem hiding this comment.
Please configure a linter (ie: flake8 or ruff
)
There was a problem hiding this comment.
ruff was implemented in this commit: 16b3389#diff-107e910e9f2ebfb9a741fa10b2aa7100cc1fc4f5f3aca2dfe78b905cbd73c0d2
|
|
||
| refDate = datetime(1970, 1, 1, 0, 0, 0, 0, pytz.utc) | ||
| self.gender = GenderType.Undefined | ||
| self.projectDescription = hdf5_string_reader(f["scanMetaData"]["Comment"]) |
There was a problem hiding this comment.
Already set at line 215. Do you need this redundancy ?
| string_size = struct.unpack(format, _read_exact(f, bytes_size))[0] | ||
| if string_size > _MAX_BINARY_STRING_SIZE: | ||
| raise ValueError(f"binary string is too large: {string_size} bytes") | ||
| return _read_exact(f, string_size).decode("utf-8").strip("\x00 ") |
There was a problem hiding this comment.
read_string_binary (utils.py:81-104) reimplements the same pattern by hand instead of calling _read_struct:
string_size = struct.unpack(format, _read_exact(f, bytes_size))[0]
This is exactly _read_struct's body (struct.unpack(format, _read_exact(stream, size))[0]), just with bytes_size passed in explicitly rather than derived via struct.calcsize(format) — which would give the same number anyway, since a format string alone always determines its size. That call could be struct.unpack(format, _read_exact(f, struct.calcsize(format)))[0] → i.e. just _read_struct(f, format), removing the redundant bytes_size parameter and the duplicated logic. Minor, but it's the kind of small duplication that's easy to miss because the two functions live in the same file a few lines apart.
| return np.array([[sx, 0, 0, 0], [0, sy, 0, 0], [0, 0, sz, 0], [0, 0, 0, 1]]) | ||
|
|
||
|
|
||
| def decrypt_data(value: np.ndarray, n: int) -> np.ndarray: |
There was a problem hiding this comment.
if this function is only used for Raw files, should it not live in the Raw class as a static methiod ?
Hint :
class Raw:
class MetaData:
@staticmethod
def _decrypt_data(value: np.ndarray, n: int) -> np.ndarray:
"""Decrypt raw data encrypted in first versions of '.raw' files."""
value_array = np.asarray(value, dtype=float)
if value_array.size == 1:
nbrc: np.ndarray = value_array.reshape(-1)[0]
else:
nbrc = value_array
nbr: np.ndarray = nbrc.copy()
if nbrc.ndim < 3:
nbr = (nbrc - 72) / (1005 * n)
return np.asarray(nbr)
def __init__(self, fileheader) -> None:
with h5py.File(fileheader, "r") as h5:
self.transmitFrequency: float = _first_value(self._decrypt_data(h5["F1"], 1))
...| nbrc = value_array | ||
| nbr: np.ndarray = nbrc.copy() | ||
| if nbrc.ndim < 3: | ||
| nbr = (nbrc - 72) / (1005 * n) |
There was a problem hiding this comment.
Please explain what is this about with some explicit comment
|
|
||
| ## Development Workflow | ||
|
|
||
| Use the `dev` branch as the base for pull requests. The `master` branch is reserved |
There was a problem hiding this comment.
we'll leave the dev branch for internal devs. Other users will need to create other ad hoc branches that will be merged by iconeus into dev and successively into master, when a version is declared
| - Add or update tests for behavioral changes. | ||
| - Describe compatibility or data-format implications in the pull request. | ||
| - Confirm that tests, coverage, linting, formatting, and type checking pass. | ||
| - Request review before merging into `dev`. |
There was a problem hiding this comment.
Iconeus devs will merge PRs
…ormatting nits - AcquisitionMode was documenting raw legacy .scan string labels instead of the actual IntEnum members (fUS2D, Angio3D, fUS3D, fUS3DCustom); add a note on the legacy RCA labels that remap to fUS3D/Angio3D - Document the weightUnit attribute, referenced by weight but never listed - Fix tab-indented RST field descriptions in raw_format.rst/roi_format.rst (same class of bug fixed for usage.rst in PR #3) - Fix stray italics, double space, and Windows venv activation command mismatch between README.md and installation.rst
docs: fix AcquisitionMode enum names, missing weightUnit field, and formatting nits
…n + moved checkfourCC to utils
Scan fixes before publish
| self.probe.probeType = Probe.ProbeType.Linear | ||
| self.voxels = data | ||
| elif ( | ||
| len(data_shape) > 4 |
There was a problem hiding this comment.
Please add this logic to a dedicated static method. Use it here and in can_be_consolidated also
|
Changes have been reviewed and comments adressed in PR #8 |
Full review of the code