rg314 / pytraction

Bayesian Traction Force Microscopy
BSD 3-Clause "New" or "Revised" License
3 stars 1 forks source link

Updating pytraction to later versions #52

Open rg314 opened 3 years ago

rg314 commented 3 years ago

Do I need to make any changes in the config.yaml? I am getting following error:

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
/tmp/ipykernel_282/1756007441.py in <module>
      4 config = '../config/config.yaml'
      5 
----> 6 traction_config = TractionForceConfig(E=E, scaling_factor=pix_per_mu, config=config)
      7 
      8 

~/miniconda3/envs/pytraction/lib/python3.8/site-packages/pytraction/core.py in __init__(self, scaling_factor, E, min_window_size, dt, s, meshsize, device, segment, config)
     35             self.config = self._get_config(min_window_size, dt, E, s, meshsize, scaling_factor, segment)
     36         else:
---> 37             self.config = self._config_ymal(config, min_window_size, dt, E, s, meshsize, scaling_factor)
     38 
     39 

~/miniconda3/envs/pytraction/lib/python3.8/site-packages/pytraction/core.py in _config_ymal(config, min_window_size, dt, E, s, meshsize, scaling_factor)
     71     @staticmethod
     72     def _config_ymal(config, min_window_size, dt, E, s, meshsize, scaling_factor):
---> 73         config['tfm']['E'] = E,
     74         config['tfm']['pix_per_mu'] = scaling_factor
     75         config['tfm']['meshsize'] = meshsize

TypeError: string indices must be integers

Originally posted by @l-kaplan in https://github.com/rg314/pytraction/issues/44#issuecomment-891628783

rg314 commented 3 years ago

It looks like the install of the latest version hasn't worked since the new code should read as followed:

    @staticmethod
    def _config_yaml(config, E, min_window_size, s, meshsize, scaling_factor):
        with open(config, 'r') as f:
            config = yaml.load(f, Loader=yaml.FullLoader)

        config['tfm']['E'] = E,
        config['tfm']['pix_per_mu'] = scaling_factor
        config['piv']['min_window_size'] = min_window_size if min_window_size is not None else config['piv']['min_window_size']
        config['tfm']['s'] = s if s is not None else config['tfm']['s']
        config['tfm']['meshsize'] = meshsize if meshsize is not None else config['tfm']['meshsize']
        return config

Try uninstalling and reinstalling. Make sure you pull the latest changes as well :)

i.e. something like this:

cd GitHub/pytraction
git pull
conda actviate [your pytraction env]
pip uninstall pytraction
pip install .
rg314 commented 3 years ago

@l-kaplan any luck?

l-kaplan commented 3 years ago

Well the reinstall did help to get it to run, but I am still getting the artifacts.. Mh maybe I’m missing something.

rg314 commented 3 years ago

I just realized that I pushed with non default configs!

Please make sure that crop_aligned_slice is set to True

settings:
  bead_channel: 0
  cell_channel: 1
  segment: False
  device: cpu
  crop_aligned_slice: True
l-kaplan commented 3 years ago

Yes! This did the trick, thanks for the troubleshoot. I'll go on and process the rest of the images then!

rg314 commented 3 years ago

@rg314 updating needs to be added to the docs