Skip to content

Review of the first version before publication - #1

Closed
danieleTrimarchi wants to merge 156 commits into
masterfrom
dev
Closed

danieleTrimarchi wants to merge 156 commits into
masterfrom
dev

Conversation

@danieleTrimarchi

Copy link
Copy Markdown

Full review of the code

@simoncampredon-lang simoncampredon-lang self-assigned this Aug 27, 2026
Comment thread src/pyiconeus/models/Scan.py Outdated

class Dim6:
class Dim6Intent(IntEnum):
ClutterFiltering = (0,)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why (0,) instead of : 0 ?
Same question for the following values, as well as the values in clutterFilterType

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

outdated, changed in recent versions

Comment thread src/pyiconeus/models/Scan.py Resolved
Comment thread pyproject.toml

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please configure a linter (ie: flake8 or ruff
)

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment thread src/pyiconeus/models/Scan.py Outdated

refDate = datetime(1970, 1, 1, 0, 0, 0, 0, pytz.utc)
self.gender = GenderType.Undefined
self.projectDescription = hdf5_string_reader(f["scanMetaData"]["Comment"])

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Already set at line 215. Do you need this redundancy ?

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix here: d615748

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 ")

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix here: 3b9e813

Comment thread src/pyiconeus/utils/utils.py Outdated
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:

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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))
                ...

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix here: 7435726

Comment thread src/pyiconeus/utils/utils.py Outdated
nbrc = value_array
nbr: np.ndarray = nbrc.copy()
if nbrc.ndim < 3:
nbr = (nbrc - 72) / (1005 * n)

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please explain what is this about with some explicit comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fix here: 7435726

Comment thread CONTRIBUTING.md Outdated

## Development Workflow

Use the `dev` branch as the base for pull requests. The `master` branch is reserved

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed here: 7403489

Comment thread CONTRIBUTING.md Outdated
- 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`.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Iconeus devs will merge PRs

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

changed here: 7403489

Jferrier99 and others added 2 commits August 28, 2026 14:08
…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
Comment thread src/pyiconeus/models/Scan.py Outdated
self.probe.probeType = Probe.ProbeType.Linear
self.voxels = data
elif (
len(data_shape) > 4

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add this logic to a dedicated static method. Use it here and in can_be_consolidated also

@danieleTrimarchi

Copy link
Copy Markdown
Author

Changes have been reviewed and comments adressed in PR #8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants