BodenmillerGroup / ImcSegmentationPipeline

A pixel classification based multiplexed image segmentation pipeline
https://bodenmillergroup.github.io/ImcSegmentationPipeline/
MIT License
83 stars 35 forks source link

sort analysis stack channels by mass (closes #88) #89

Closed jwindhager closed 2 years ago

nilseling commented 2 years ago

I got this error when running the updated chunk in the pre-processing script:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
Input In [8], in <cell line: 3>()
      3 for acquisition_dir in acquisitions_dir.glob("*"):
      4     if acquisition_dir.is_dir():
      5         # Write full stack
      6         imcsegpipe.create_analysis_stacks(
      7             acquisition_dir=acquisition_dir,
      8             analysis_dir=final_images_dir,
----> 9             analysis_channels=sort_channels_by_mass(
     10                 panel.loc[panel[panel_keep_col] == 1, panel_channel_col].tolist()
     11             ),
     12             suffix="_full",
     13             hpf=50.0,
     14         )
     15         # Write ilastik stack
     16         imcsegpipe.create_analysis_stacks(
     17             acquisition_dir=acquisition_dir,
     18             analysis_dir=ilastik_dir,
   (...)
     23             hpf=50.0,
     24         )

File ~/Github/ImcSegmentationPipeline/src/imcsegpipe/utils.py:163, in sort_channels_by_mass(channels)
    162 def sort_channels_by_mass(channels: Sequence[str]) -> List[str]:
--> 163     return sorted(channels, lambda channel: int(re.sub("[^0-9]", "", channel) or 0))

TypeError: sorted expected 1 argument, got 2
jwindhager commented 2 years ago

Sorry about that, should be fixed now