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

Automatically install missing packages #43

Merged
merged 10 commits into from
Jul 16, 2024
Merged

Conversation

jcohenadad
Copy link
Member

@jcohenadad jcohenadad commented Jul 12, 2024

This is a branch off of #41

TODO:

TODO in subsequent PRs:

Comment on lines -1549 to +1627
segm_data = segm.get_fdata()
segm_data_dtype = segm.dataobj.dtype
print(f'infile: {input_path}, dtype: {segm_data.dtype}')
if segm_data.dtype != np.uint8:
if segm_data_dtype != np.uint8:
segm_data = segm_data.astype(np.uint8)
segm_nii = nib.Nifti1Image(segm_data, segm.affine)
segm.header.set_data_dtype(np.uint8)
segm_nii = nib.Nifti1Image(segm_data, segm.affine, segm.header)
Copy link
Member Author

Choose a reason for hiding this comment

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

These changes seem unrelated to package management. For the sake of clarity in the git history, should we do avoid unrelated changes in this PR, and address these changes in another, more specific, PR?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yes, sorry, I should have created another issue and PR specific to this, a small bug I found while testing the module. Note: .get_fdata() returns a floating point image so if segm_data.dtype != np.uint8: would always have returned False.

Comment on lines -6 to +18
modality: 'MRI' # 'CT' or 'MRI'
modality: 'CT' # 'CT' or 'MRI'
slice_view_color: 'Red' # 'Red' or 'Yellow' or 'Green'

interpolate_value: 0
interpolate_value: 1

impose_bids_format: True
impose_bids_format: False

is_classification_requested: True
is_segmentation_requested: True
is_semi_automatic_phe_tool_requested: True

ct_window_width: 85
ct_window_level: 45
Copy link
Member Author

Choose a reason for hiding this comment

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

Also unrelated to package management

@jcohenadad jcohenadad changed the title Contribution to package import management Automatically install missing packages Jul 12, 2024
@jcohenadad
Copy link
Member Author

jcohenadad commented Jul 12, 2024

Tested on fresh Slicer install, and issue related to the missing qt import:

Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/Applications/Slicer.app/Contents/lib/Python/lib/python3.9/imp.py", line 169, in load_source
    module = _exec(spec, sys.modules[name])
  File "<frozen importlib._bootstrap>", line 613, in _exec
  File "<frozen importlib._bootstrap_external>", line 850, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/Users/julien/code/slicer-manual-annotation/SlicerCART/src/SlicerCART.py", line 67, in <module>
    check_and_install_python_packages()
  File "/Users/julien/code/slicer-manual-annotation/SlicerCART/src/SlicerCART.py", line 52, in check_and_install_python_packages
    response = qt.QMessageBox.question(slicer.util.mainWindow(), 'Install Extensions', msg,
NameError: name 'qt' is not defined
[Qt] loadSourceAsModule - Failed to load file "/Users/julien/code/slicer-manual-annotation/SlicerCART/src/SlicerCART.py"  as module "SlicerCART" !
[Qt] Fail to instantiate module  "SlicerCART"
[Qt] The following modules failed to be instantiated:
[Qt]    SlicerCART
[Qt] Populating font family aliases took 106 ms. Replace uses of missing font family ".AppleSystemUIFont" with one that exists to avoid this cost. 

Although qt seems to be already installed inside Slicer's Python, so we can just import it

@jcohenadad
Copy link
Member Author

Example of qt box on Slicer fresh install:

image

@jcohenadad jcohenadad merged commit 12b1f64 into main Jul 16, 2024
@jcohenadad jcohenadad deleted the jca/38-package-import branch July 16, 2024 22:14
@jcohenadad jcohenadad mentioned this pull request Jul 17, 2024
@jcohenadad jcohenadad added this to the 0.1 milestone Jul 17, 2024
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.

2 participants