ivoflipse / Pawlabeling

Tool for processing and analyzing pressure measurements
Other
18 stars 1 forks source link

Issue with updating the currently selected contact #66

Closed ivoflipse closed 10 years ago

ivoflipse commented 10 years ago

While this may be a side-effect of all the mocking around I've been doing, there seems to be an issue with updating the current contact on the contactswidget.

image

ivoflipse commented 10 years ago

Because I no longer recalculated the average data after assigning each contact, as soon as a measurement lacked any stored contacts, it didn't have an average and so the contact widgets didn't know how to (properly) size them, so we could predict their label

ivoflipse commented 10 years ago

There's an issue where when I switch between measurements/subjects, there's a shape mismatch. So while you don't necessarily see it, there's still something fishy going on.

Traceback (most recent call last):
  File "C:\Dropbox\Development\Pawlabeling\pawlabeling\widgets\processing\processingwidget.py", line 251, in select_right_front
    self.next_contact()
  File "C:\Dropbox\Development\Pawlabeling\pawlabeling\widgets\processing\processingwidget.py", line 316, in next_contact
    self.update_current_contact()
  File "C:\Dropbox\Development\Pawlabeling\pawlabeling\widgets\processing\processingwidget.py", line 198, in update_current_contact
    contacts=self.contacts)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\publisher.py", line 30, in sendMessage
    topicObj.publish(**kwargs)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\publishermixin.py", line 24, in publish
    self._publish(msgKwargs)
  File "C:\Anaconda\lib\site-packages\pubsub\core\topicobj.py", line 340, in _publish
    self.__sendMessage(data, self, iterState)
  File "C:\Anaconda\lib\site-packages\pubsub\core\topicobj.py", line 359, in __sendMessage
    self._mix_callListener(listener, data, iterState)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\publishermixin.py", line 64, in _mix_callListener
    listener(iterState.filteredArgs, self, msgKwargs)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\listenerimpl.py", line 27, in __call__
    cb(**kwargs)
  File "C:\Dropbox\Development\Pawlabeling\pawlabeling\models\model.py", line 324, in update_current_contact
    current_contact_index=self.current_contact_index)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\publisher.py", line 30, in sendMessage
    topicObj.publish(**kwargs)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\publishermixin.py", line 24, in publish
    self._publish(msgKwargs)
  File "C:\Anaconda\lib\site-packages\pubsub\core\topicobj.py", line 340, in _publish
    self.__sendMessage(data, self, iterState)
  File "C:\Anaconda\lib\site-packages\pubsub\core\topicobj.py", line 359, in __sendMessage
    self._mix_callListener(listener, data, iterState)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\publishermixin.py", line 64, in _mix_callListener
    listener(iterState.filteredArgs, self, msgKwargs)
  File "C:\Anaconda\lib\site-packages\pubsub\core\kwargs\listenerimpl.py", line 27, in __call__
    cb(**kwargs)
  File "C:\Dropbox\Development\Pawlabeling\pawlabeling\widgets\processing\contactswidget.py", line 85, in update_contacts
    normalized_current_contact[offset_x:offset_x + x, offset_y:offset_y + y, 0:z] = current_contact.data
ValueError: could not broadcast input array from shape (83,22,183) into shape (83,1,132)
ivoflipse commented 10 years ago

This problem is because I don't have an average shape all contacts should adhere to when there's nothing saved yet. So I should make a function that determines the maximum dimensions and then have all contacts use that, until we encounter a new measurement, then we rinse and repeat.

Either the contacts we just looked at are in the database, so load_contacts should pick that up. Or they aren't and we don't care about them anyway for this new measurement, so we want the new dimensions.

ivoflipse commented 10 years ago

I changed the workflow again, now when you create a measurement, you also create its contacts (assuming tracking works just fine). This means that model.load_contacts will always find all contacts for all measurements in the session, so we should be able to estimate the right size. The only issue right now is that when there have been no contacts assigned yet, this shape isn't accessible in contacts widget.

The easy solution is to notify all relevant functions of the size they should be using.

ivoflipse commented 10 years ago

Since the calculation of average_data has been changed, I removed all calls to sliced_data and simply trust on model.calculate_average to return the correct value