[addon] Classifier

https://raw.githubusercontent.com/ChrisRaven/FlyWire-Classifier/main/Classifier.user.js

I’ve made this small addon as a quick way to roughtly separate cells by type.

To use it, right-click on the “change color” patch:

right-click

There should a popup window showing list of available categories:

Select the category appropriate for a given cell and click the OK button.

To see all the classified cells, click on the “Get classified cells” button at the top bar:

There should be another window with all the ids added to each of the groups:

Now you can copy all the IDs by clicking the “Copy” button in each row. Then open a new FW tab and paste those IDs.
You can also remove all the cells of a given type (the “Remove” button).

What this addon doesn’t do:

  • it doesn’t send the classification to the server,
  • it doesn’t display status of each cell,
  • it doesn’t check, if a cell has already been classified,
  • it doesn’t warn you, if you want to remove all the ids.

It’s just a simple tool for quick splitting of large “farms” to smaller groups with given types.
I’m not planning to do any upgrades to this addon (I’m a little burnt out with programming), only fixes. But, if there will be an excellent idea easy to implement, I might do it.

If anyone want to have their own categories, just edit the addon in the Dashboard of the TamperMonkey.
Go to line 92. There should be an array named “types”. Change the entries to anything you want (there can be more or less entries - it doesn’t matter) and the entries will be displayed both during assigning a cell to a group and when you’re viewing the already assigned cells.

6 Likes

Very nice!!

1 Like

v. 0.1.1

Added vertical scrolling, when needed.

v. 0.1.2

Fixed the Copy button.

v. 0.1.3

Added Copy All button. This one allows copying all the entries with the groups’ names. It’s a way, to make a backup, for example, in a text file, if someone wants to.

1 Like

Oh this is perfect for the farm I’ve been working on , which I’ve been using group annotations for to try to keep types sorted. Thank you!

3 Likes

You’re welcome :slight_smile:
I’ve already (today) went through over 200 cells. Of course, the precise identification will be harder, but, I hope, grouping them together make it at least a little bit easier.

3 Likes

I don’t want to add too much to your coding load but here are a couple of points of feedback:

  • You can label the same cell multiple times, including for the same type, resulting in duplicates. You also can’t see which have been labeled or not from the segment selection area. Neither are a major issue, but if there is some way to show whether or not a cell has been classified through the add-on it’d be helpful.
  • Likewise, it would be useful to have a way to show/hide groups of cells through Classifier.

Overall though I’m already loving this and it will be very useful as I continue to build this farm out - it will be much easier to manage and work with than the annotations.

3 Likes

It would be doable to mark, which cell has already been labeled, but would require quite a bit of code to track down all the changes in the segment list and whether the list is currently being displayed or not.
The way, I’m currently dealing with this situation is:

  • copy the current state (via the Share button) and work on such copy,
  • update all outdated cells,
  • remove a cell immediately after labeling it (this step being the solution for duplicates and unlabeled cells)

As for the duplicates, it’s not a big problem, because FW will recognize, if a fragment is already added and won’t add it again.

Agree, that showing and hiding the groups would be useful. I’ll think about this one.

The idea for this addon was to use it like a series of sieves/buckets - the way, the archeologists and prospectors do to roughly classify their dirt, gravel and stones. And in the same way, I wasn’t planning to use the “buckets” as a long-time storage place. Just do the classification and then work with the material using other methods. That’s why I wasn’t planning to add many more functionalities.

2 Likes

Makes sense about tracking segment list changes, etc! Actually I was thinking that the classification was only for a specific ‘instance’ (ala link/view) and didn’t realize this classification was global / persistent. Don’t know why I thought that :sweat_smile:

So actually, it’s not too bad to have it as it is!

Is there a way to manually edit the saved list of IDs that we have? Say for instance if we wanted to move a cell out of a previous classification?

3 Likes

Unfortunately, there’s no easy way to edit the list. You’d have to use the browser’s console, and then use this snippet to modify the data:

var storage = Sifrr.Storage.getStorage('indexeddb')
storage.get('kk-classifier').then(res => {
      let saved = res['kk-classifier']
      for (const [key, values] of Object.entries(saved)) {
        const index = values.indexOf(/*the ID, you want to remove, in form of a string*/);
          if (index > -1) {
            values.splice(index, 1)
        }
      }
      storage.set('kk-classifier', { value: saved })
})

I didn’t test the code though (only the syntax), but I think, it should work. Use at your own risk :smiley:
It’ll remove all the entries of a given ID, not only a duplicate, so you’ll have to add it again manually.

3 Likes

This is amazing!

What do you think about if the field Other could be filled in with open text? I bet there are a lot of researchers who would use this. Do you have a way to automatically add labels to the cells?

2 Likes

I’ve said before, that I’m not going to add much to this addon, only some things, that might be both useful and easy to implement. I think, possibility to change the labels is one of those things.
So, I’m gonna add a way to edit all the labels. After all, it just a simple manual sorting tool and because it’s simple, it could be more versatile.

If you’re saying about cell identifications sent to the FW server, I don’t have a way to do it automatically.
It would probably require to have not only ID of a cell, but also coords of a point somewhere within the cell. For now, working without adding the coords is easier and quicker, because one doesn’t have to center the xyz cursor inside the cell and wait for the 2D to be loaded. It’s enough to right-click on the color-patch and you’re ready to select a label.

3 Likes

Thanks! Another nice addon :grinning:

1 Like

I found out, that there’s an easier method to edit the saved list. You can use a Chrome addon called IndexedDBEdit. It’s not my script so I can’t guarantee it’s perfectly save, but I’ve used it recently and it seems to be ok. You still have to use the Console, but it’s much easier, than that my code snippet.

1 Like

Cool. Yeah tagging cells is tricky!

Thanks again for this, it’s fantastic

1 Like

v. 0.2

Added ability to edit all the labels. By default, the labels are named after all the types seen in the Optic Lobe, but they can be changed to anything. There are 30 slots available (if one needs more, a simple edit in the code can help with that).
To edit the labels, click the “Get classified cells” button at the top bar and then click the “Edit Labels” button. Add/change the names and press the OK button.

I’ve also changed the look slightly (smaller font for the IDs, wider dialog windows, the Copy All button at the top, bigger spaces between some elements, different colors, etc.)

As always, I can’t guarantee, that everything will work ok right away, but I’ve tested it and, so far, no problems.

2 Likes

I do love the new UI changes. The update ‘cleared’ my custom labels that existed previously, thankfully I backed up most of them yesterday and can re-add them.

However the labeling menu does not scroll/extend far enough - I added four today (T2, T3, T4, T5) and T5 is not showing. I can access it only by clicking on T4 and then using the arrow key down to select the next entry.

image

2 Likes

Sorry about the clearing. I’ve tried to prevent it by doing some migration code and it worked for me, but it probably worked, because I’ve already had some changes made in the database by some earlier drafts of the new version of the code. Good, that you had a backup :slight_smile: .

I’ve pushed version 0.2.0.1 with the fix to the labeling menu.

2 Likes

No worries! I figured as a new script with custom data it would be smart to keep a back up just in case. :slight_smile:

The labeling menu fix works,thank you!

2 Likes

Have you considered the possibility to a just add the labels you need when working in a certain area instead of the full list, that would take care of the need for scrolling. ofc then it would be useful to have a reset too deafult button to get the full list if needed.

I know this is probably more programming than you would like too do at the moment, but have you considered the possibility to add a custom colour to each label so it would easier to show the difference betwheen cell types in 3d

2 Likes

I’ve added a button to reset labels to defaults (v. 0.2.1).

I didn’t think about adding colours to labels. I’ll think about it, but for now, it sounds like a lot of coding.

3 Likes