GSoC 2024 Project Idea 18.4 Package Brian’s unit system (175h/350h)

Brian is a clock-driven spiking neural network simulator which is easy to learn and use, highly flexible and easy to extend. It is written in Python and allows describing and running arbitrary neural and synaptic models without having to write code in any other programming language. One of Brian’s features is that it comes with a system to express quantities with physical dimensions, and will automatically check the consistency of these dimensions when such quantities are combined. While there are a number of other Python packages with similar features, Brian’s unit system has a few unique features and could therefore be useful to the wider community. The aim of this project is to turn Brian’s unit support into a library that is distributed separately from Brian. This is an interesting opportunity to learn about Open Source development, and the infrastructure around package development (documentation, tests, packaging, …). The specific aims of this project are:

  • Package the code from brian2.units into an independent package
  • Set up the framework for tests and documentation, adapting the existing tests and docs
  • Revisit/refactor the current package structure if necessary, and decide upon reasonable defaults for the provided units
  • Systematically test the performance for common use cases

Additional goals for a 350h project:

  • Implement useful features from other unit packages, e.g.:
    • integration with matplotlib’s unit system (pint)
    • string formatting (pint, Quantiphy)
    • type annotations (astropy units)
    • integration with pandas (pint-pandas)

Skill level: Novice/Intermediate

Required skills: Python

Time commitment: Part-time or full-time

Lead mentor: Dan Goodman (d.goodman@imperial.ac.uk)

Project website: https://github.com/brian-team/brian2/

Backup mentors: Marcel Stimberg (marcel.stimberg@sorbonne-universite.fr)

Tech keywords: Python, packaging

Hello @d.goodman @mstimberg,

My name is Sorin Birchi, and I am a 2nd year undergraduate student at the National University of Science and Technology Politehnica of Bucharest, Romania. Besides university, I learn a lot by myself and also I teach a python course through a CISCO program. I would like to contribute for this project because I find it very helpful for the future, and I aspire to be one of the people who will work on it. I also have two questions. Firstly, I am curious about the roadmap for learning and working on this project. At the moment, I believe a good starting point would be to fully understand brian2, but I am uncertain about what materials I should delve into next. Secondly, regarding the proposal for this project, should I contribute on GitHub first, or is it acceptable if I only document and ask questions about what is not clear?

Thanks in advance!

Hi @Sorin_Birchi, many thanks for your interest in the project – and many apologies for the late reply! To get familiar with Brian (and in particular with its unit system), I’d have a look at Introduction to Brian part 1: Neurons — Brian 2 2.5.4 documentation and Physical units — Brian 2 2.5.4 documentation to learn about the unit system from the user’s side, and at Units — Brian 2 2.5.4 documentation for more details from the developer’s side. In addition to being familiar with Brian’s approach, it would also be useful to get an idea of how it differs from other existing solutions such as pint, quantiphym or astropy units. Please don’t hesitate to ask any questions you might have!

Finally, for some general advice about the project proposal, please have a look at GSoC 2024 | The Brian spiking neural network simulator

Thanks a lot for your reply @mstimberg! I will start to read the documentation and if I have other questions I will post them here.

Have a nice and productive day!

Hello @mstimberg @d.goodman
My name is Favour James and I am a final-year student of electronic and electrical engineering at Obafemi Awolowo University, Nigeria. I am a Machine learning engineer with an interest in the health field domain. I use Python for data science and machine learning and got very interested in this project when I came across it because I have always been interested in open-source development and improving my skills greatly in open-source development.
I was opportune to participate in GSoC last year under another organisation and here is the project I worked on: Google Summer of Code

Before I proceed with my application, I have some questions I hope you can clarify for me:

  1. I noticed that the project goals include integrating features from other unit packages such as matplotlib’s unit system and pandas. Could you elaborate on which specific functionalities from these packages are most critical for the Brian unit system integration?
  2. For testing the units’ performance, are there predefined performance metrics that I should focus on? Also, could you provide examples of the common use cases that are most relevant for evaluating the units’ performance?
  3. In terms of refactoring the current package structure, do you have a vision for how you would like the new independent package to be organized, or are there any known limitations of the current structure that you’re aiming to overcome with this project?
  4. Do i need domain expertise in neuroscience to participate in this project?

Thank you very much and I look forward to your response

Hi @Favourj-bit, happy to hear you are interested in the project!

Here a few pointers

Note that the proposed features are part of the “stretch goal” for a 350h project, none of them are critical for what we have in mind for the project, and they are also just examples of nice-to-have features that I am aware of. The initial phase of the project would also be about researching the existing packages, and figure out what additional features they offer that could be relevant for us. Of the features I mentioned above, I’d be most strongly interested in the “type annotations” feature (as an additional syntax/replacement for the check_units decorator: Functions — Brian 2 2.6.0 documentation).

We only have a very small number of things we currently check, see https://github.com/brian-team/brian2_benchmarks/blob/01a3a91642d32fb481ba9b44cb83c6877ee41839/benchmarks/benchmarks.py#L514-L530, but the general idea is that the unit system should only add minimal overhead to the time that numpy takes to do the calculation.

For now, I don’t have a clear vision for the details of the new structure – the only mandatory requirement is that it is an independent package outside brian2 :slight_smile:

No. Domain-wise all you’d need is some general physics knowledge (i.e. basic familiarity with scientific units, prefixes, etc.).

Hope that gives you a clearer idea, please let me know if you have other questions or if anything was unclear!

Hello @d.goodman @mstimberg,
I am Karen Fifi NKILI OBELE, a computer engineering student at the African Informatics Institutes (IAI) in Gabon. I aspire to become a data scientist, so I learned Python.
As I have a late start, I will do best to read the documentation that you shared in the earlier post. If I have a question, I will post them here.
If you have any advice for me, please do tell.

Thanks in advance.

HI @Obele, happy to hear that you are interested in the project. Please have a look at the links posted earlier and don’t hesitate to let me know in case anything is unclear!

Hello! I have a question regarding the application process. Is it possible to receive feedback on my application from somewhere else before I submit it on the GSoC platform? @mstimberg

@Sorin_Birchi. Definitely, here’s the respective quote from the GSoC article from our website:

While it is not a strict requirement, we highly recommend to base your application on the INCF GSoC Application template. As soon as you have a draft that you’d like to have feedback on, please contact us directly (e.g. over a direct message on neurostars) with a link to the draft – a Google Docs document is probably the easiest solution.

Thank you very much. I am clear with the questions and I will start working on a proposal and send you a draft immediately for your review

:loudspeaker: Dear prospective candidates, please be aware that the submission deadline for application proposals is Apr 2nd. Unfortunately (well, not for me :wink: ), I will be away for a break over the Easter weekend and can therefore not give extensive feedback close to the deadline date. Please send me a draft before Wed 27th for detailed feedback. I will still be reachable after that date, but most likely not be able to look into your document in detail. Thanks for your understanding and happy proposal writing :blush: ! :loudspeaker: