Latest / Talk Python To Me / #461: Python in Neuroscience and Academic Labs
Transcript
- 0:00Do you use Python in an academic setting?
- 0:01Maybe you run a research lab or teach courses using Python.
- 0:05Maybe you're even a student using Python.
- 0:08Whichever it is, you'll find a ton of great advice in this episode.
- 0:11I talked with Keelan Cooper about how he's using Python in his neuroscience lab at the
- 0:16University of California, Irvine.
- 0:18And Keelan wanted me to let you know that if any developers who are not themselves scientists
- 0:22are interested in learning more about scientific research and ways you might be able to contribute,
- 0:27please don't hesitate to reach out to him.
- 0:30This is Talk Python To Me, episode 461, recorded March 14th, 2024.
- 0:35Are you ready for your host?
- 0:37There he is.
- 0:38You're listening to Michael Kennedy on Talk Python To Me.
- 0:42Live from Portland, Oregon, and this segment was made with Python.
- 0:45Welcome to Talk Python To Me, a weekly podcast on Python.
- 0:53This is your host, Michael Kennedy.
- 0:55Follow me on Mastodon, where I'm @mkennedy, and follow the podcast using
- 0:59at Talk Python, both on fosstodon.org.
- 1:02Keep up with the show and listen to over seven years of past episodes at talkpython.fm.
- 1:08We've started streaming most of our episodes live on YouTube.
- 1:11Subscribe to our YouTube channel over at talkpython.fm/youtube to get notified about upcoming
- 1:17shows and be part of that episode.
- 1:19This episode is sponsored by Neo4j.
- 1:22It's time to stop asking relational databases to do more than they were made for and simplify
- 1:27complex data models with graphs.
- 1:30Check out the sample FastAPI project and see what Neo4j, a native graph database, can do for you.
- 1:37Find out more at talkpython.fm/Neo4j.
- 1:41And it's brought to you by Posit Connect from the makers of Shiny.
- 1:45Publish, share, and deploy all of your data projects that you're creating using Python.
- 1:50Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs.
- 1:56Posit Connect supports all of them.
- 1:59Try Posit Connect for free by going to talkpython.fm/Posit, P-O-S-I-T.
- 2:04Hello, how are you?
- 2:06I'm doing well.
- 2:07So awesome to have you here on Talk Python and talking academics.
- 2:12I didn't tell you before we hit record, but I spent a long time at universities and I just love them.
- 2:18They're such cool places and it's going to be really fun to get a look inside how Python's
- 2:23being used there.
- 2:23Yeah, well, thank you so much for having me.
- 2:25And yes, I too love universities.
- 2:27It's kind of like all the coolest parts of humanity just kind of intermixing in one place.
- 2:33So yeah, I'd love to kind of peel back the curtain on how things are going by.
- 2:37Yeah, yeah.
- 2:37Well, we're talking about how you and your colleagues use Python and data science inside of your
- 2:43neurology research lab.
- 2:45But before we dive into that, let's just get a bit of background on yourself.
- 2:49Who are you?
- 2:49How do you get into Python?
- 2:51All those things.
- 2:52So I'm Keelan Cooper.
- 2:52I'm a neuroscientist at the University of California, Irvine.
- 2:56So Southern California, 15 minutes from the beach and an hour from the mountains.
- 3:00But I'm originally from the middle of nowhere, Indiana.
- 3:04And I started playing with computers and code when I was young.
- 3:08So like middle school ish, just ripping apart computers and seeing what was in them and then
- 3:14trying to put them back together and feeling bad when they didn't work right after.
- 3:18And then the typical, you know, tweaking the software when you don't like what it does
- 3:22until you make it work.
- 3:23And then probably my senior year of high school is when I started teaching myself Python.
- 3:28And it was because we had to do some for some government class, actually.
- 3:32Oh, wow.
- 3:32Okay.
- 3:33And we had to learn.
- 3:34We were learning about the stock market.
- 3:35And every day you'd have to spend like 15 minutes going to like some stock website and like filling
- 3:40out your fake stocks.
- 3:42And so I wrote a really small Python script that would just pull the data from the website
- 3:46and populate like an Excel spreadsheet.
- 3:49And so every day the kids in the class were just like going through and like spending 15,
- 3:5320 minutes by handwriting it down.
- 3:55And I would just sit there.
- 3:56That's awesome.
- 3:56And so that was kind of the first time I was like, wow, this whole automation thing is pretty
- 4:00sweet from there.
- 4:02I thought I just kind of caught the bug pretty early.
- 4:04Python was definitely the way to go.
- 4:06Was Python your first programming language?
- 4:09First programming language was the Windows registry and trying to undo all of the mistakes
- 4:14of the operating system.
- 4:15It's been a while since I've been in the Windows registry, but good old reg edit.
- 4:20I switched to Linux pretty quick.
- 4:21Linux and Unix.
- 4:23Are you still on Linux?
- 4:23Mostly.
- 4:24My desktops are all Linux.
- 4:25My servers are obviously all Linux.
- 4:27I like Mac for a laptop just because, you know, Linux has this thing where you tinker
- 4:32with it.
- 4:32And so then any small task you want to do, you end up like rewriting some deep script in
- 4:37the operating system.
- 4:38And like two hours later, you're like, what was that small thing I was trying to do again?
- 4:41Yeah, exactly.
- 4:42I got distracted.
- 4:43I was rewriting something in there and off we go.
- 4:45Yeah.
- 4:46Yeah.
- 4:46So Macs are nice because you still have all the same Unix like properties that are great,
- 4:51but you pay a price for reliability.
- 4:53You just sell a bit of your soul out, but boy, is that UI nice and those little menu
- 4:58bar apps are handy.
- 4:59You know, I was...
- 5:00It's a little.
- 5:00That's right.
- 5:02I was...
- 5:02I've been playing with running Ubuntu on my Mac M2 Pro, which it runs great, but it's
- 5:10an ARM version of Mac, of Linux rather.
- 5:13Well, both really.
- 5:14But boy, is there a limited supply of applications for an ARM Linux distribution.
- 5:21Linux.
- 5:22Let me tell you, they're like, just download the Debian package.
- 5:25I imagine that'll change pretty quick though.
- 5:27Yeah.
- 5:27They're like, just download the Debian package.
- 5:28You just install it.
- 5:29Like wrong platform.
- 5:30Like again, over half.
- 5:33But yeah, I think it will change as I think ARM's going to start to take over Windows a little
- 5:37bit as well.
- 5:38And obviously the Mac world is basically transitioning.
- 5:41So anyone who has a Mac.
- 5:43Yeah.
- 5:43I think it's Qualcomm that just kind of started hinting that they were going to try and really
- 5:48heavily compete with the M line of processors and have some pretty good specs.
- 5:52So it'll be good.
- 5:53I have an M3 and it's pretty nice.
- 5:56It is really nice.
- 5:57Like I said, I like to run more stuff on it, but it's still kind of Intel or x86 stuff
- 6:02for Linux and Windows.
- 6:04So it's a little hard to work with that, but still super fun.
- 6:07That's a long way to say it's a very long time since I've been in a reg edit.
- 6:11Personally, it sounds like you as well being not naming Windows too much.
- 6:16I'm so bad at Windows now, like when I'm helping people with Python or something else and they
- 6:20show me their computer, there's always that like 10 minute learning curve of like, okay,
- 6:25how do I, how do I do anything basic on this machine?
- 6:29Or even like the keyboard shortcuts you get so accustomed to when people don't have any of
- 6:33those little things that you're just like, how do I, how do I select everything?
- 6:37And that is it.
- 6:38Like I did professional software development on Windows for a long, long time.
- 6:41I even wrote a bunch of Windows apps.
- 6:43It was, it was great.
- 6:44But going back and forth too quickly, that or Linux, like just the hotkeys, I just get
- 6:49broken.
- 6:49Not just on Windows.
- 6:51Also, when I come back to Mac, like I'm just completely out of sorts.
- 6:54So yeah, it's fun.
- 6:56All right.
- 6:57Well, let's talk academics and Python from a, probably a OS, mostly agnostic perspective.
- 7:05But yeah, just, you know, give us a sense of the kind of research you do.
- 7:08You know, what is your field?
- 7:09What do you study?
- 7:10Those kinds of things.
- 7:11So people get a sense of like, why am I talking?
- 7:14Where are you coming from as you talk about doing all these things?
- 7:16The core of my work is pure neuroscience.
- 7:19So, so basic science.
- 7:21What we do mainly in the lab is we take really tiny wires.
- 7:25So they're like a fifth of the size of the human hair.
- 7:28And now we're using something called silicon probes, which are, they're manufactured the
- 7:31same way that computer chips are manufactured on silicon wafers using photolithography.
- 7:37Do you get a higher density that way?
- 7:38Do you get like a bunch of little sensors on one point or something?
- 7:42Okay.
- 7:42So we used to build these little drives.
- 7:44I used to have one here, but I got rid of it.
- 7:46Little drives by hand.
- 7:47So you would just feed the wires in with, with forceps.
- 7:51And so you'd get maybe 64 or 128 at most, depending on how much time you want to sit there and
- 7:57feed the wires in.
- 7:58Yeah.
- 7:58But now you can just get the manufactured.
- 7:59You pay a lot more, but you get twice, three times the sites.
- 8:03And the whole point is the more sites you have, the more neurons you can actually record
- 8:08from in the brain.
- 8:09Yeah.
- 8:10You're not just saying this part of the brain lit up, but you can have a much better picture,
- 8:14right?
- 8:14The constituent part of your brain is the neuron.
- 8:17And so of the millions and billions of neurons, depending on the species you're recording from,
- 8:22we can record maybe a few hundred of them.
- 8:25But that's usually sufficient to actually, in the specific region you study, and I can talk
- 8:30about that more, to discern some sort of information from it.
- 8:33And so really the data type we really care about is this tiny little electrical voltages
- 8:37that tell you what different neurons in the brain are talking about.
- 8:41And so you put the wires in, you record the conversations of a bunch of neurons.
- 8:46And then particularly we're interested in two brain regions that are critical for memory,
- 8:51learning, and decision-making.
- 8:53And this is the hippocampus, which in humans is about the size of your pinky and a few
- 8:58inches in from your ear.
- 8:59And the prefrontal cortex, which most people know about right behind your forehead, important
- 9:03for learning, decision-making, and all those sorts of things.
- 9:06Yeah.
- 9:06So that's the core of my work is I'm in the lab doing the actual data collection and building
- 9:11equipment to actually do that.
- 9:13But once you have all of that data and the data keeps growing, like most other fields, you
- 9:17got to do a lot of pre-processing, which takes Python.
- 9:20You got to do a lot of post-processing, which takes a lot of Python.
- 9:23And also we do something called neural decoding.
- 9:26So not only do we just like say descriptively, what are these neurons doing?
- 9:31But we can go one step further and say, what actual information are these cells representing?
- 9:37So in the brain, we can kind of say, this is kind of the fundamental kind of information
- 9:44transfer and how information is manipulated in the brain and how it ships information from
- 9:49the environment into memory and how it uses that to make a decision.
- 9:53All of those kinds of things we can use through fancy modeling and statistics and more recently,
- 9:59deep learning and those sorts of things.
- 10:00We'll have to come back to deep learning later.
- 10:02That'll be fun.
- 10:03Given your background.
- 10:05So for this hardware, do you write the software that actually talks directly to the hardware
- 10:11or is there something that just records it and you grab some sort of custom file format and
- 10:16run with it?
- 10:17Yeah.
- 10:17More recently, it kind of depends on the lab.
- 10:21So as time goes on, there's more and more companies that you can just buy off the shelf and
- 10:26recording platforms, mostly for the electrical engineering people.
- 10:30It's kind of like an audio amplifier because you're recording at millivolts in the brain.
- 10:33So you have to amplify it, write it to, if you're plugged in with a wire, write it to the
- 10:38computer.
- 10:38So all that takes software in various forms.
- 10:41And then we do a lot of animal research.
- 10:44So the tasks that the animals do are pretty much all automated.
- 10:49But recently in the lab, we've kind of had this resurgence of developing kind of novel hardware
- 10:55and a lot of automation of behavior.
- 10:56So I've kind of rewritten most of our entire behavioral stacks, which is a lot of just some
- 11:03microcontroller programming, which not a lot of that's in Python.
- 11:06A lot of that's just kind of like C++ and those sorts of things.
- 11:09But we have cameras all over.
- 11:11So I wrote this kind of like camera server that streams all of the camera footage from
- 11:16a bunch of automated boxes to some like central server that just collects all of that data.
- 11:20So yeah, a lot of the behavioral stuff nowadays, we're just building in-house to collect all
- 11:26of the behavior data.
- 11:27The EFIS stuff is now, especially because we're doing something called wireless recording.
- 11:32So instead of just having a wire plugged into the head, it just writes it to like an SD card
- 11:36or Bluetooth.
- 11:37That's just kind of all on chip.
- 11:39So it's just whatever the microcontroller language of the chip needs.
- 11:44This portion of Talk Python To Me is brought to you by Neo4j.
- 11:49Do you know Neo4j?
- 11:51Neo4j is a native graph database.
- 11:54And if the slowest part of your data access patterns involves computing relationships,
- 11:58why not use a database that stores those relationships directly in the database, unlike your typical
- 12:05relational one?
- 12:06A graph database lets you model the data the way it looks in the real world, instead of forcing
- 12:10it into rows and columns.
- 12:12It's time to stop asking a relational database to do more than they were made for and simplify
- 12:18complex data models with graphs.
- 12:20If you haven't used a graph database before, you might be wondering.
- 12:24About common use cases.
- 12:25What's it for?
- 12:26Here are just a few.
- 12:27Detecting fraud.
- 12:28Enhancing AI.
- 12:30Managing supply chains.
- 12:32Gaining a 360 degree view of your data.
- 12:35And anywhere else you have highly connected data.
- 12:38To use Neo4j from Python, it's a simple pip install Neo4j.
- 12:44And to help you get started, their docs include a sample web app demonstrating how to use it
- 12:48both from Flask and FastAPI.
- 12:51Find it in their docs or search GitHub for Neo4j Movies Application Quick Start.
- 12:56Developers are solving some of the world's biggest problems with graphs.
- 13:00Now it's your turn.
- 13:01Visit talkpython.fm/Neo4j to get started.
- 13:06That's talkpython.fm/Neo4j.
- 13:09And the letter J.
- 13:10Thank you to Neo4j for supporting Talk Python To Me.
- 13:15I think it's surprising how much software and even hardware, but definitely software is involved
- 13:22for something that doesn't sound like a software discipline.
- 13:25Yeah.
- 13:25You wouldn't think of what you guys are doing as inherently almost like a software team,
- 13:30but there's a lot of software there.
- 13:31Absolutely.
- 13:32And it's growing.
- 13:32So it used to be 10, 20 years ago, more biology, I'd say, like more wet lab stuff.
- 13:38But 90% of what I do as kind of a neurobiologist is really just engineering style things.
- 13:45Like I'm more recently designing PCBs and I'm in the shop a lot, just like with saws and
- 13:51hammers and drills and like actually physically building things.
- 13:54And obviously a lot of code.
- 13:55And the coding part is becoming bigger and bigger to the point where in the field, I always say
- 14:00that the neuroscience is like about three decades behind astrophysics.
- 14:05Because all the problems that like neuroscientists, like say we're facing now as a field, they
- 14:09have like three decades prior where in astrophysics, they're like, well, or neuroscience, we're
- 14:14like, what do we do with all this data?
- 14:15This is, I mean, I'm collecting a hundred gigabytes an hour, if not more, like what do we do?
- 14:21That is a lot.
- 14:21Yeah.
- 14:22But relative to like some of those big telescopes that are collecting like almost petabyte scale.
- 14:28I would say both ends of physics, like the very, very extreme ends of physics.
- 14:32So astrophysics, the very large and then particle physics, right?
- 14:36At CERN as well, they've got insane amounts of data.
- 14:39Yeah.
- 14:39And that's what we're starting to see.
- 14:40I think in neuroscience too, is that kind of division of like, because the scale of data
- 14:45collection is so big, you're starting to need not just a single lab, but teams.
- 14:49So we have a few institutes now that are just pumping out terabytes of data.
- 14:53And so you start to see that division between the neuroscientists who are really in the lab,
- 14:59hands-on with actual neural tissue or the recording device, and the neuroscientists who
- 15:04are just take the data and analyze it and develop new models and statistical models.
- 15:09And also theory, there's always a dearth of theory in neuroscience, but the computational
- 15:14modeling is certainly getting a lot bigger within the last few decades as well, where people's
- 15:20entire job is just how do we model some of these things in code?
- 15:24You probably run into different research groups, different teams that have different levels
- 15:29of sophistication from a software side.
- 15:32And do you see like a productivity or a quality difference jump out from like the kind of work
- 15:37or the velocity of work that people are doing there?
- 15:39Absolutely.
- 15:40It makes me almost like a, it's a huge range.
- 15:44There are like very sophisticated labs.
- 15:46And usually those are the labs that have kind of just a pure software person on the team or
- 15:51people who are very inclined towards software all the way to, and it makes me so sad when people
- 15:56are spending like weeks in a spreadsheet, just manually doing things by hand.
- 16:00Yeah, I know.
- 16:00You could do this in five minutes and by a minute.
- 16:03And not only could you do it faster, you could do it without any errors.
- 16:07Yeah, more reliable.
- 16:08None of those like, oh, I misread it and I shifted off by a cell or I typed in, I missed
- 16:15something, right?
- 16:16Because it just reads what's there.
- 16:17Yeah.
- 16:18A lot of like graduate programs are starting to wake up to this fact that it's going to
- 16:23be almost impossible to do any science without some degree of proficiency in coding.
- 16:28And I think a lot of, a lot of say grad students and postdocs and so on, when they actually sit
- 16:33down and try and analyze their data, whether they're just in Excel or they need to write
- 16:38a little Python script, that's kind of their first introduction is, oh, I have this data.
- 16:42I need to do something with it.
- 16:43I'm going to Google exactly how do I read in this data or how do I do a t-test in Python
- 16:49or how do I plot something in matplotlib?
- 16:51And that's kind of the level that they start getting into out of necessity.
- 16:54But the sophistication and the speed, because that's, they're usually just teaching themselves.
- 16:59That's most of academia.
- 17:01It's just, you have a problem, spend a few days Googling and reading books until you find
- 17:06it.
- 17:06And once it works, you can kind of just leave it.
- 17:08You don't have to clean it up or anything, right?
- 17:10Yeah.
- 17:11Okay.
- 17:11Which results in a lot of, I mean, the progress of science doesn't go away, but the code is,
- 17:17you know, not robust.
- 17:18And so that's why you see things, especially in other fields of like psychology and such
- 17:22like replication crises.
- 17:23And people have done meta analysis of running the same software stack on like 12 different
- 17:29data sets and you get different results.
- 17:31And so you start to kind of see that shaky foundation is starting to bleed into the, like
- 17:37you said, the reliability results.
- 17:39And starting to have consequences, not just it's more work or something.
- 17:42Exactly.
- 17:43Maybe we could start a bit by just talking about maybe the history, you know, diving into this
- 17:48a little bit more, just the history of programming in neuroscience.
- 17:51I wasn't in neuroscience in any way, but I worked with a bunch of cognitive scientists studying,
- 17:58you know, how people solve problems and thought about things at a lab for one of my first jobs.
- 18:03And we studied all through eye tracking.
- 18:04Yeah.
- 18:05Not the iPhone, but actual eyes.
- 18:07It was fascinating.
- 18:08It was tons of data.
- 18:08It was really cool.
- 18:09And there were like, you described a lot of people who would do sort of Excel stuff and
- 18:13they would take the data and they process it.
- 18:14And over time, we just started to automate these things.
- 18:17And their first thought was, you're programming me out of a job.
- 18:20I'm like, no, no, no.
- 18:22This is the crappy part of your job.
- 18:24Like you're supposed to analyze the results and think about it and plan new stuff.
- 18:27And now you can just focus on that.
- 18:29Right.
- 18:30And as the software got better, you know, we just tackled bigger problems.
- 18:34So, you know, maybe give us a bit of a history of on your side.
- 18:37So I love the cognitive science.
- 18:39That's my more background is cognitive science.
- 18:42I was my undergrad and grew up in science in a cognitive science department while also
- 18:47doing some wet lab neuroscience stuff.
- 18:49So it's fun.
- 18:50Yeah, absolutely.
- 18:51Did you start out with like MATLAB and that kind of stuff?
- 18:54Is that where they told you you need to be?
- 18:56Neuroscience has certainly had at least our branch of neuroscience just because by the nature
- 19:02of recording voltages and you need to write to a computer.
- 19:05So there has been kind of a long history of for as long as there's been even like punch
- 19:11card computers.
- 19:11People have kind of read in the data into the computer and done, you know, their statistics
- 19:17on that rather than something else.
- 19:19I'm just I'm actually recently writing a kind of a review article on kind of the history
- 19:24of data science and neuroscience.
- 19:25And I loved this paper.
- 19:28It was from 1938.
- 19:30And they took an EEG spectrum.
- 19:33And so EEG is just the continuous time series of brain voltage.
- 19:38So you're not in the brain recording.
- 19:39And this is, I think, from humans.
- 19:41And they took something called the Fourier transform, which I'll be as up to speed with that is you
- 19:45basically just take some oscillating signal and you break it down into its constituent parts.
- 19:51And most of you have seen it before.
- 19:52If you've ever seen like an audio spectrogram, that's kind of the most notable visualization
- 19:58where you can kind of see the high frequencies and the low frequencies.
- 20:00Basically, it pulls the frequencies out of the signal, right?
- 20:04Yeah.
- 20:04But the way they did this, this is 1938.
- 20:07There's no computers.
- 20:07So they actually had mechanical device where they would just take this EEG trace that was
- 20:13on tape and they would feed it into this like mechanical machine.
- 20:17And it would basically read kind of this black line on the tape.
- 20:20And so as it would crank the tape around this machine, depending on kind of the frequency that
- 20:27the line went up and down, that would read out the Fourier transform.
- 20:30So it was mechanical, like a lot of those cool devices back in the older days.
- 20:35That's impressive.
- 20:36Now you can get that same thing with in MATLAB.
- 20:39You just type FFT, parentheses, parentheses, put your data in the middle and you get the
- 20:43same thing in microseconds.
- 20:45But neuroscience, at least my field, has kind of always had this kind of serendipitous relationship
- 20:51with computing generally, coding generally.
- 20:53And a lot of the code, I think earlier on was kind of was Fortran-ish and then it moved
- 20:58towards MATLAB and MATLAB's kind of had its stake in the ground for a long time.
- 21:03Just because that was the first kind of software that you could really do array manipulations
- 21:08on well.
- 21:08And it was kind of a higher level than some of the lower level programming.
- 21:11So a lot of the older labs have their entire code base and stack and analysis software in
- 21:18MATLAB.
- 21:19And so it's only been within maybe five to six, seven years, it'll be a bit longer,
- 21:2410 years that you've really seen Python start to supplant MATLAB as kind of the de facto
- 21:29programming language in labs, just because of the cost of trying to transfer everything over.
- 21:35And despite the fact that MATLAB isn't open source and it's extremely expensive, most universities
- 21:40have licenses.
- 21:41And so that kind of facilitates...
- 21:43It's prepaid.
- 21:44Yeah.
- 21:44In a sense.
- 21:45Yeah.
- 21:45But it is still pretty expensive.
- 21:47Especially if you get those little toolboxes, like wavelet decomposition toolbox, 2,000 bucks
- 21:52instead of a pip install, you know?
- 21:54And again, we do a lot of signal processing.
- 21:55And so that's exactly the place you want to be.
- 21:58And like MATLAB usually controls, because it has pretty good control over like external hardware,
- 22:03you can run like your behavior, your task kind of in MATLAB codes.
- 22:07You can kind of do everything in one language as you would like to do in Python.
- 22:11But it's starting to kind of go away.
- 22:14And I think a lot of that is just because the allure of Python, which is so many tools,
- 22:19and because it's probably a lot easier to learn for most people than MATLAB.
- 22:23We're kind of starting to see that switch now that there's kind of more to offer, I'd say,
- 22:28a lot of scientists than MATLAB.
- 22:31Yeah, you said 10, 12 years ago.
- 22:32At least in our film.
- 22:33Yeah, the difference in the external packages on PyPI you can get,
- 22:37and especially the ones for data science have just exploded.
- 22:43The choices and the stuff that's out there, it's pretty diverse.
- 22:46It's pretty crazy.
- 22:47The only other one that I think is still in pretty strong competition with Python
- 22:50from the perspective of, we collaborate a lot with like mathematicians and statisticians,
- 22:55and R is their usual favorite, just because statistics,
- 22:59like all the best statistical packages are still pretty much in R.
- 23:03And so that's where a lot of people live.
- 23:05TG Plot's pretty good.
- 23:07Pretty mixed plots.
- 23:08Yeah, that's interesting.
- 23:10It's really focused, and it's really good at what it does.
- 23:13And one of the things that I think is worth just considering,
- 23:16if somebody comes, let's say a brand new first year grad student comes into the lab,
- 23:22and you're like, all right, what's your programming experience?
- 23:24Like, well, program the clock on the VCR.
- 23:27Like, okay, we're going to have to start you somewhere or something, right?
- 23:30And you could teach them something really specific, like MATLAB, or something along those lines.
- 23:36But if they learn something like Julia, not like Julia, like Python, not Julia, maybe even not really R, but R is closer somewhat,
- 23:45is they learn not just a skill for the lab, but it's kind of almost any software job is potentially within reach,
- 23:53with a little bit of learning about that area, right?
- 23:55Like, if you know Python, you say, I want a job, there's a massive set of options out there.
- 23:59If you say, I know MATLAB, or even Julia, it's like, okay, well, here's the few labs and the few research areas and the real,
- 24:09I just think it's something that-
- 24:11A lot of engineering firms.
- 24:12Yeah, yeah.
- 24:13I'm just thinking that, like, a lot of academic folks should consider what happens if the student doesn't necessarily become a professor.
- 24:20You know what I mean?
- 24:21Which actually is a lot of the time, right?
- 24:23Or a professional researcher of some sort.
- 24:25And that's a really awesome skill to have on top of your degree.
- 24:29So I think that's just a big win for it.
- 24:31I'm happy to see that.
- 24:32And that literal situation just happened where a statistician that we were collaborating pretty closely with graduated,
- 24:38brilliant guy, and got a job at Microsoft.
- 24:42And so we were in a meeting after he was there, and they were like,
- 24:46what's some advice that you have now that you've been, you know, in industry for a while?
- 24:50And he's like, stop using R.
- 24:51Learn Python, because everyone here uses Python.
- 24:54And it took me a few months to kind of switch from the R worldview of, you know,
- 25:00caret hyphen to equal sign to actually to work and collaborate with everyone, because everyone's just using Python.
- 25:07Yeah.
- 25:07From his perspective, and I'm sure it's not unique.
- 25:10No, I'm sure that it's not either.
- 25:12I think, yeah, I just think it's, it's not like a religious war.
- 25:15It's not like, oh, I think Python is absolutely better.
- 25:17You should just not use other stuff.
- 25:18I just think it's preparing people for stuff beyond school.
- 25:22It's a pretty interesting angle to take.
- 25:24And it's not like you can't learn other things.
- 25:25I think it's really good to learn other things, especially ones that are complementary, where R can be complementary, especially now that they have a lot of the, like, subsystem packages.
- 25:35Or when I get R code, I usually just write, like, a subprocess.
- 25:39I did this recently, just wrote, like, a subprocess line to call the R script, because I was too lazy to rewrite it.
- 25:45Yeah, sure.
- 25:45But there's other, like, I don't know, like, Rust is probably a good one to probably try and branch out.
- 25:50Or, like, lower level languages, like C++.
- 25:52Yeah.
- 25:52If you need for what you're doing.
- 25:54Yeah, and it sounds like you guys do for talking to hardware and stuff like that.
- 25:57Yeah, occasionally.
- 25:58Boy, there's not a lot of things Python can't do.
- 26:01Break out some MicroPython when you got to get your microcontrollers and stuff.
- 26:04This portion of Talk Python To Me is brought to you by Posit,
- 26:08the makers of Shiny, formerly RStudio, and especially Shiny for Python.
- 26:14Let me ask you a question.
- 26:15Are you building awesome things?
- 26:17Of course you are.
- 26:18You're a developer or a data scientist.
- 26:20That's what we do.
- 26:21And you should check out Posit Connect.
- 26:23Posit Connect is a way for you to publish, share, and deploy all the data products that you're building using Python.
- 26:30People ask me the same question all the time.
- 26:33Michael, I have some cool data science project or notebook that I built.
- 26:37How do I share it with my users, stakeholders, teammates?
- 26:39Do I need to learn FastAPI or Flask or maybe Vue or React.js?
- 26:45Hold on now.
- 26:45Those are cool technologies, and I'm sure you'd benefit from them, but maybe stay focused on the data project.
- 26:50Let Posit Connect handle that side of things.
- 26:53With Posit Connect, you can rapidly and securely deploy the things you build in Python.
- 26:57Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, ports, dashboards, and APIs.
- 27:04Posit Connect supports all of them.
- 27:06And Posit Connect comes with all the bells and whistles to satisfy IT and other enterprise requirements.
- 27:12Make deployment the easiest step in your workflow with Posit Connect.
- 27:16For a limited time, you can try Posit Connect for free for three months by going to talkpython.fm/posit.
- 27:22That's talkpython.fm/P-O-S-I-T.
- 27:26The link is in your podcast player show notes.
- 27:28Thank you to the team at Posit for supporting Talk Python.
- 27:31So another thing that's, I don't know how it's received.
- 27:36I know it took a while to kind of really catch on.
- 27:39And I think the thing that just broke the final barriers for open source being adopted, at least in business, was the AI stuff and the data science stuff.
- 27:49People were like, oh, we can't use this open source stuff.
- 27:51We've got to have a SLA and some company we can sue if our code doesn't work right or, you know, whatever, right?
- 27:56Something crazy like that.
- 27:57And they're like, but you understand all the AI and all the data science.
- 28:02We have to use this open source stuff.
- 28:03Like, all right, fine.
- 28:04What's the open source story for you guys?
- 28:07Academia is probably championed open source for a really long time just because, I mean, open source back, I mean, even when I first started, it was just if you read a paper and someone has some new fancy analysis.
- 28:20Before it became a bigger push by, like, funding agencies to, like, actually post it to GitHub or some repository.
- 28:26I mean, you could just email people and be like, hey, I saw your paper.
- 28:29I want that script.
- 28:30And they would just send you a MATLAB file.
- 28:32And it would be, you know, just whatever they had written.
- 28:35But it was in MATLAB and you'd have to kind of tear it apart yourself.
- 28:38And there was little to no documentation.
- 28:39You'd be lucky if there's comments and it's, you know, spaghetti code.
- 28:43But, you know, you figure that out.
- 28:45You kind of work backwards and deconstruct it.
- 28:47And eventually you kind of have their code.
- 28:49So that kind of ethos of just, you know, scientists are really good, by and large, of just sharing information and helping people out.
- 28:57If you have a question, just ask.
- 28:58It's kind of always been there.
- 29:01At least in our field, it's not as competitive as some other ones where you're just kind of like racing to get the next project out.
- 29:08It happens, but rarely.
- 29:09But now a lot of funding agencies and just in general, people are just excited about when you publish a paper, you put a GitHub link in the bottom of the paper.
- 29:18And then that links to the repository.
- 29:20And, yeah, maybe it's not been updated in a while, but the code's there and you can just take it and grab it.
- 29:25For the reproducibility.
- 29:26How about using other things?
- 29:28Is there SciPy?
- 29:29I know for astronomy, there's AstroPy.
- 29:31Is there Neuropy?
- 29:33It's really still more analysis-dependent and pre-process-dependent.
- 29:38So there's kind of this, it's still the early days where there's probably too many formats just because no one can agree on what's the best one.
- 29:46So like even a lot of the data formats are written kind of in Python to take whatever data you have and reformat it to something shareable.
- 29:53And there's five or six of them floating around.
- 29:55There's probably two that are still duking it out to see which one will be the best.
- 29:59And probably five years from now, there's going to be a better one.
- 30:02So data formats, certainly there's kind of this, there's a few that are neck and neck.
- 30:07Analysis pipelines, a lot of those are still done in-house, but they're starting to be a lot more toolkits and frameworks and packages.
- 30:13There's some really good ones that have more documentation written.
- 30:17They're on the PyPy repositories.
- 30:19So you can just pip install them and you have them.
- 30:21The computational neuroscience people are great at this.
- 30:24So all the like neural simulation software, that is all really well documented, really well written.
- 30:30A lot of good like example code and tutorials and so on.
- 30:34So yeah, we're starting to see kind of this more robust kind of ecosystem where you can just kind of pull things.
- 30:41It still just kind of varies.
- 30:42There's probably still not one go-to place other than the standard data science toolkits.
- 30:48Right, right.
- 30:49The pandas and so on.
- 30:51Yeah, NumPy, Matplotlib, pandas, scikit-learn, if you're doing deep learning, PyTorch or TensorFlow, all of those still apply to any data site stack.
- 31:00Yeah, of course.
- 31:00What's your day-to-day stack look like if you're sitting down to do some analysis?
- 31:05I have a VS Code and like autocomplete where I just write import in and it just NumPy, Matplotlib, pandas.
- 31:13Then I usually delete pandas because unless I have a CSV file, I'm not using it.
- 31:17So NumPy, Matplotlib, I can probably do 75% of the things I want to do.
- 31:22scikit-learn and SciPy, obviously, if I'm doing any stats with those things, those libraries I might go to.
- 31:28And then over the last few years, I kind of just have my own, just because you catch yourself writing the same functions over and over and over again.
- 31:36And so I just started building my kind of internal framework of just things I know I need.
- 31:40So if I'm working with LFP data, I have all my filters there.
- 31:44If I have spike data, I have all my spikes there.
- 31:46We do a lot of decoding, so developing deep learning algorithms to decode neural data.
- 31:52All of those are kind of listed there.
- 31:54Yeah, and then I started realizing, dude, internal tools make the difference between solving a problem in 10 minutes or solving it in an hour, where I can just sit down and have everything automated to come up.
- 32:06So yeah, the standard data science stack I use pretty frequently.
- 32:09Hardware stack, I mean, so VS Code, I just recently switched to just because everyone was talking about it from Sublime.
- 32:17I usually just edit it in a terminal.
- 32:19And I was like, oh, I'll try it out.
- 32:21Everyone's talking about it.
- 32:21It's one of the good things Microsoft has done.
- 32:24It's pretty sweet.
- 32:25Yeah, it is pretty sweet.
- 32:26That's pretty nice.
- 32:27And when you do the VS Code stuff, are you just writing straight Python scripts or are you doing VS Code on top of notebooks?
- 32:34Yeah.
- 32:34Because it has that kind of text view of a notebook type of thing, I think.
- 32:38I used to use exclusively Python scripts, so just the .py.
- 32:42Started seeing how great Jupyter was.
- 32:44And so then you start doing everything in Jupyter, and then you start to have all these convoluted notebooks and notebook V1 through 7.
- 32:51So then you realize that you've got to find a balance between, you know, notebooks are great for presentation and for quickly testing.
- 32:58But the sooner you can get it into, like, a class structure or a package or something.
- 33:02The sort of productized version of it, you wanted to get it down into Python code a lot of times, probably.
- 33:08Exactly.
- 33:08Like your internal tools you talked about.
- 33:10You're like, all right, this is the library you just call stuff, right?
- 33:12That just belongs more as a package and not a...
- 33:15The sooner you can kind of condense, pull the code out of the notebook and just leave notebooks for presentation, it's probably the best.
- 33:22Yeah.
- 33:23It's a lot of pipelines.
- 33:24So it's a lot of preprocessing pipelines.
- 33:25So you don't want, you know, 50 cells of just moving data.
- 33:29Preparing, yeah.
- 33:30You talked about having quite a bit of data, some of that being image-based.
- 33:34Sounds like a lot of work.
- 33:36Do you have, like, a big compute cluster?
- 33:37Do you just have, like, an ultra, an M3 ultra or whatever?
- 33:42That's not even not yet.
- 33:43It's M2s.
- 33:44But do you have just a big machine or do you guys do cloud stuff?
- 33:47What's compute look like?
- 33:48Depends on what I'm doing, what I need.
- 33:50Most things, let's be honest, I could probably just use my desktop computers, really a super micro server.
- 33:56It just runs Linux.
- 33:57But then for doing deep learning, you need GPUs.
- 34:00And so we have a nice set of GPUs we can pull, too.
- 34:04Yeah.
- 34:05Do you do your own training on LLMs and other deep learning things?
- 34:08The only LLM training I did was just for fun.
- 34:10But it's all the deep learning stuff we have to train.
- 34:13And it's on R, particularly.
- 34:15So that's all GPUs for that.
- 34:17A lot of the statistics we do are, like, permutations.
- 34:20So you need to kind of, like, parallelize them out into CPUs.
- 34:24So then I'll pull, like, a CPU cluster we have if I need it.
- 34:27Do you see Irvine have, like, a big compute resource sort of thing you can grab?
- 34:31They have a campus-wide one that you can get on.
- 34:33And there's a few independent ones that I have access to.
- 34:37So GPU is kind of in a different place than CPUs are.
- 34:40So I can just kind of pick and choose.
- 34:42And then I have a few servers in the lab that I've just kind of put together.
- 34:46All my camera stuff, all my behavior, I kind of wrote it so it's cloud-based.
- 34:51So I can kind of just pull up my phone and look at the videos of what animals are doing and stuff.
- 34:55All that runs on just a server in the lab.
- 34:58So, yeah, it's the compute is there when you need it.
- 35:01And I think as I've matured, I've kind of learned when to use what compute when and when it's worth taking the extra time to use it when you don't need to.
- 35:09And also when a lot of the times you don't even need it.
- 35:12So I know a lot of people when I see their code and they complain that it takes like an hour to run.
- 35:17I mean, just using multiprocessing in Python, that in and of itself is enough to not need to use a cluster.
- 35:25They're just using a single thread for their analysis.
- 35:28For sure.
- 35:28Or just a bad programming patterns.
- 35:30design patterns.
- 35:31Like you're looping over the thing in the Pandas data frame instead of doing vector operations in the Pandas data frame.
- 35:38Like that kind of stuff, right?
- 35:39A hundred percent.
- 35:40Yeah.
- 35:41I mean, that was one of the first things that I usually teach.
- 35:44I have this little example script that shows that like, why is it better to pre-allocate array rather than to just append to the bottom?
- 35:50And it's like these things that we kind of take for granted now, but it's not intuitive unless you actually see it.
- 35:55No, you learn it the hard way, but it sticks in your mind once you learn it.
- 36:00Well, yeah, I think that's the issue.
- 36:01It's like people just take it for granted.
- 36:03Yeah, for sure.
- 36:03Like, why didn't you know that?
- 36:05How do you onboard new people?
- 36:08It just kind of depends on the lab.
- 36:14Every lab kind of has their own structure of just kind of this hierarchy of expertise where like I started as an undergrad and I just volunteered in a lab at a different university and just volunteered my time.
- 36:26Eventually could get paid.
- 36:28Just wanted to spend time in the lab and you could all the way up to grad students who are there to get a PhD and have more kind of autonomy over their projects.
- 36:35A postdoc who has a PhD and five to eight years of experience.
- 36:41And so it can pretty work well.
- 36:42Then there's like staff scientists or even a lot of labs now are hiring just pure engineers or pure software people.
- 36:48Okay.
- 36:48Because there's such a need for that.
- 36:50And so, yeah, it really just depends on the lab specific situation and what their focus is on and what they need.
- 36:56Cool.
- 36:56I guess if you have a good NSF grant and you got some extra money, it might be money well spent to hire some student who has good programming skills, right?
- 37:03Absolutely.
- 37:04Yeah.
- 37:05You talked about the video stuff that you're doing, the streaming video.
- 37:08Do you actually do analysis on that or is it just for you to go back and look at?
- 37:12Oh, yeah.
- 37:13Yeah.
- 37:13We do analysis on that.
- 37:14There's actually a pretty cool deep learning package out now.
- 37:17We didn't write it.
- 37:18Another lab did where you just give it the video frame and it can automatically segment kind of it's an animal.
- 37:24So, like where their paws are or where their like nose is looking or in some cases people have like you're talking about eye tracking.
- 37:30They do eye tracking in like mice now.
- 37:32They do eye tracking on mice.
- 37:34That was hard on humans in the 90s.
- 37:36Yeah.
- 37:36There's a lot of VR.
- 37:37So, they put kind of mice in this like VR system.
- 37:40Oh, wow.
- 37:41And they can like see where their little mouse pupil is looking on like the VR screen.
- 37:45Yeah.
- 37:45And do they show them different scenarios and they can detect that and they react to it?
- 37:49Oh, absolutely.
- 37:49Incredible.
- 37:50So, yeah.
- 37:50And a lot of stuff, at least in our field, the Nobel Prize was awarded for you stick some electrodes in the hippocampus part of your brain that's important for learning and memory.
- 38:00And then you have the animal kind of run around some environment.
- 38:03And then you take some video data of kind of where they were running the environment.
- 38:07And if you were only looking at the brain data, you can predict to like 90 some percent accuracy the location of the animal.
- 38:15So, you can show this kind of this correspondence that inside the brain is a map of kind of the environment.
- 38:20Our stuff, we're taking that a little one step further that says this map is not just for space.
- 38:25It's for non-spatial and other things too.
- 38:28There's this kind of network of information in the brain that the animal can kind of like navigate through, even if they're just standing still but thinking about some sort of problem.
- 38:36But we use video data to validate what the animal's doing or check what kind of tasks they're doing and so on.
- 38:42So, yeah, a lot of multimodal heterogeneous data that each needs its own funky pre-processing.
- 38:48And depending on the task at hand, you're writing something new to ask that question.
- 38:53So, is that OpenCV?
- 38:54Yeah, my stuff is OpenCV and streamed over sockets and some Django webpage.
- 39:00It's fun.
- 39:01It's cool to build.
- 39:02That sounds really cool.
- 39:03Yeah, absolutely.
- 39:04So, what kind of questions are you answering with the video?
- 39:07Yeah.
- 39:07Or is it just to correlate back with the time series of what you're measuring in the brain?
- 39:11So, like I said, the Nobel Prize was for this spatial map.
- 39:14We're doing this non-spatial stuff.
- 39:16And so, we kind of do both in the lab where we have an animal kind of run around and then we have an animal just kind of sit still
- 39:23and do some sort of mental task.
- 39:25In our case, it's a – they have to memorize a sequence of odors and if the sequence gets shuffled, they make a different choice.
- 39:31And so, we're basically showing how does the brain work for the spatial part versus the non-spatial part?
- 39:37What's similar about these two things?
- 39:39What's different about these things?
- 39:40And we show that the – one of our recent papers was that the brain uses a lot of the similar mechanisms to navigate space as it does to navigate this kind of non-spatial odor task.
- 39:50But we also showed that there's this mechanism that the brain uses to take kind of discrete memories and link them together into some kind of mirror hole.
- 39:58Best case being like this talk we've been talking back and forth for 30-some minutes now.
- 40:03Inside, there's kind of chunks of the conversation.
- 40:05So, if tomorrow someone was to ask you, what did you and that neuroscience guy talk about on your podcast?
- 40:10You would kind of rattle off this story of, oh, we talked about history of Python and this and this and this, right?
- 40:17This, this, and this are each kind of discrete memories that in your brain you kind of lock together and store them.
- 40:24So, you could use them, make decisions about them and so on and so on.
- 40:28Think about it as a whole, not just the little ideas, every little idea, but like just the big concept of it, right?
- 40:33Exactly, yeah.
- 40:34And it's a fundamental thing that the brain does.
- 40:37Like people say humans are storytellers and your life is kind of the sequence of events of stories.
- 40:42And so, you use that every single day.
- 40:44And across a bunch of diseases, that's one of the first things to actually be impaired, whether it's addiction or schizophrenia or Alzheimer's.
- 40:52That kind of ability to link things in time and link them well and make decisions about them starts to get impaired.
- 40:59That's not great when that happens, but that is what happens, right?
- 41:01Absolutely, yeah.
- 41:02But as with the software engineering practices, for lack of a better word, that you would recommend that maybe other grad students, professors who are feeling like they're not, they don't have their software game fully together, pay attention to it.
- 41:15And maybe what should they ignore, right?
- 41:17Like, should they pay attention to like source control and get up?
- 41:19Should they have unit tests or, you know, what should they pay attention to or not?
- 41:23First off, no one writes tests.
- 41:24That is just only the very few, very well put together.
- 41:28And usually people who just came from industry write tests.
- 41:31Sure.
- 41:31Which is an issue.
- 41:32But yeah, first off, just learn Python.
- 41:35I've said that hundreds of times and I'm preaching to the choir in this audience.
- 41:39You are, for sure.
- 41:41Learn Python is honestly, there's not much better you could learn.
- 41:45And two, it's, you know, it's quintessential automation stuff.
- 41:49So it's really just think about the things that you're doing, the spreadsheets or, you know, the simple things.
- 41:54And really just ask yourself, if you find yourself doing any repetitive tasks, that's a software problem.
- 41:59Those are the things to kind of look at first.
- 42:01So you have your text editor in one window, Google in the other, and stack overflow your way to learning.
- 42:06And so the way people, I think, really do kind of teach themselves Python is probably the best way to learn.
- 42:12But nevertheless, I think there is a real need for, and again, we're starting to see more of it, just formal education.
- 42:18Even if it's just a course, our program is really great that they started to teach a Python course just because the students requested it because they knew how important it was.
- 42:28Like a Python for neuroscience?
- 42:31Exactly.
- 42:32Okay.
- 42:32Yeah.
- 42:33I mean, you just work your way through if statements for loops, data types.
- 42:37You probably also, I'm just guessing you get a chance to work with some of these external libraries that are relevant to studies they're doing, right?
- 42:44Rather than, here's an example of stock market data.
- 42:46You're like, great, not a trader.
- 42:47I don't want to be a programmer.
- 42:49Why am I here, you know?
- 42:50Yeah, it's really relevant.
- 42:52And I think it's just kind of seeing like, oh, yeah, I would do that this way, but this is so much easier if I use Python.
- 42:58And I can use it in Python.
- 42:59And just seeing that, oh, it's not as bad as the mountain looks a lot higher when you're at the base than the summit.
- 43:05So it does.
- 43:06Seeing it done once is usually enough to kind of tell people it's not as bad as you originally think.
- 43:11Yeah.
- 43:12I feel like maybe I saw it this way.
- 43:14I certainly know a lot of other people see it this way.
- 43:16I mean, when I was younger.
- 43:17But a lot of people see it this way as well.
- 43:18Is it like you got to be crazy smart to do programming.
- 43:22It's really challenging.
- 43:24It's kind of one of those things that only a few people can do.
- 43:27And then you get into it and you're like, oh, it's not a few really huge steps and things you've got to solve.
- 43:33It's like a thousand small steps.
- 43:35And each one of the little small steps, you're like, that was actually easy.
- 43:38That's no big deal.
- 43:39What's the next step?
- 43:40And you get to the end, you're like, where was the big step?
- 43:42Where was it really hard, right?
- 43:43Yeah, absolutely.
- 43:44Yeah.
- 43:44Do you have some experience where people in the department or people that worked with you are like, oh, I'm not a programmer.
- 43:51I don't want to do this stuff.
- 43:51Then they kind of got into it and really found out that programming was something they really liked.
- 43:56Any converts out there?
- 43:58Yeah, I would say so.
- 43:59I mean, I think there's kind of two kinds of people.
- 44:01There's people who program just because, what is it?
- 44:04The programming is an art book or whatever.
- 44:06They love it just for the sake of loving.
- 44:08And I'm probably closer to those kind of people, right?
- 44:11I just think it's the coolest thing, like academic.
- 44:14But then there's the people who just kind of see it as like it's a tool like anything else.
- 44:18And so you could be an expert in a drill or you could just know to pick up a drill.
- 44:23That's kind of the majority of people is that it's just another tool in their toolkit, especially for a scientist, just to answer the question that you're trying to answer.
- 44:32And I would even flip the reverse where there's been some times where I've maybe even used Python too much.
- 44:38In the sense that like I made a problem more because it's like the automation dilemma, right?
- 44:43It's like, do I spend an hour automating this when I could do it in 10 minutes?
- 44:46You got to do it a lot of times and all of a sudden the hour is worth it.
- 44:49But if it turns out you don't.
- 44:50It's like I might need this a year from now.
- 44:52So I might as well just write the script.
- 44:54Whereas I could just do it in Excel.
- 44:56That's pretty standard.
- 44:57Standard problems we all run into in programming.
- 44:59It's like, write some code to do that.
- 45:01Or I could just be done with it for sure.
- 45:04All right.
- 45:05I think we've got time for a couple more topics.
- 45:07One thing that I think might be fun to talk about is publishing papers, right?
- 45:12Obviously, if you're in academics, especially in labs, you got to publish papers.
- 45:16Do you use notebooks and stuff like that for your papers?
- 45:19Or is that just kind of separate?
- 45:21What's...
- 45:22Yeah, like I said, notebooks are great for presentation.
- 45:24So yeah, I use notebooks kind of for development just because you can quickly run code and go
- 45:31back up and move things around.
- 45:32And so I kind of like that ability to kind of just a stream of consciousness, write code
- 45:37until you kind of like see how it's kind of working the prototype and then refactor out
- 45:41into an actual .py document or a package or something.
- 45:44So that's kind of been my workflow and it works pretty well.
- 45:47But then when you actually have the code and it works and it's robust, you actually want
- 45:51to put...
- 45:51There's a lot of figures.
- 45:52That's usually the main thing.
- 45:53So you kind of put all of that.
- 45:55Here's the data.
- 45:56Here's the pre-processing.
- 45:57Here's the figure one.
- 45:58Here's figure two, figure three in the notebook just so it's reproducible and other people
- 46:03can download it and rerun your code and that sort of thing.
- 46:06So I think that's slowly becoming kind of the standard approach for those labs that use
- 46:11Python and they share their code openly.
- 46:14That's kind of how they do it.
- 46:15Anything like executable books or any of those things that kind of produce printable?
- 46:20Output out of the notebooks?
- 46:22Like publishable output out of the notebooks?
- 46:24Not a lot.
- 46:25But there's one of the journals, it's called eLife.
- 46:28It's kind of...
- 46:29It's trying to like push the boundaries of what it means to publish a scientific paper.
- 46:33And so they kind of have...
- 46:35Because most papers are really just on the web nowadays.
- 46:38The journals aren't really physical journals as much anymore.
- 46:41They kind of have like papers as executable code where you can like plot the figure in
- 46:47the browser and kind of run through the notebook and just as an experiment.
- 46:50But it's pretty cool to kind of see these like new alternative ways to still convey the same
- 46:57findings.
- 46:57But you can play with it.
- 46:59You can come to CA out.
- 47:00So the methods are kind of implicit in the...
- 47:02What's the name of the journal?
- 47:03That's eLife.
- 47:04eLife.
- 47:05Okay, cool.
- 47:06Yeah, you probably, I suppose, need some way to capture the data output because you
- 47:11might not have access to the compute to recompute it.
- 47:14You know, somehow it's got to sort of be a static version.
- 47:17But that sounds really cool.
- 47:18Yeah.
- 47:19And especially for like most recently, some of our like trained models, it's becoming more
- 47:24important to just share the weights and share those sorts of things too.
- 47:27You can't just share the code to train the thing if people don't have the compute to actually
- 47:32train them themselves.
- 47:33It's kind of growing to not just sharing your data, not just sharing your code, but
- 47:37you need to share like the key derivatives of the preprocessing and those sorts of things.
- 47:41Or even just sharing the version numbers because there's been psychology or fMRI literature.
- 47:46There's like a bug in some version that like made a lot of the results null.
- 47:50And so, you know, one person could use version 3.7 of a package, but that had a bug, but people
- 47:56don't know that.
- 47:56So they claim it's not reproducible, but it's really just not the same algorithms.
- 48:00Yeah, yeah, yeah.
- 48:01Or like across languages, like if you rerun the same analysis in MATLAB versus Python versus
- 48:06R, especially complex ones, there's a lot of little design decisions under the hood that
- 48:12might tweak exactly how that regression fits or exactly how that, if you're statistically
- 48:17sampling, how the sampling works under the hood of those sorts of things.
- 48:20Awesome.
- 48:20Are you familiar with the Journal of Open Source Software?
- 48:22Yeah.
- 48:23I had the folks on from there.
- 48:25Yeah.
- 48:25I had them on quite a while ago.
- 48:27And I think they're trying to solve the interesting problem of if you take the time to create a
- 48:32really nice package for your area, you might have not taken your time writing the paper.
- 48:37And so you wouldn't get credit because you don't have as many papers to publish.
- 48:40So they let you publish like your open source work there, which I think is pretty cool.
- 48:44What do you think about that?
- 48:45We kind of had that same problem.
- 48:46One of the, I run a nonprofit called Continual AI.
- 48:51It does artificial intelligence and outreach and research, and we have conferences and all
- 48:56sorts of events.
- 48:57But one of the main things we've done is we built a deep learning library on top of PyTorch
- 49:02called Avalanche.
- 49:03And so like we had a really great community of mostly volunteers who just saw the need
- 49:08in the field and put it together.
- 49:10But then again, it's like a lot of us are academics.
- 49:12How do you present this?
- 49:13And so you write wrapper papers around kind of the framework.
- 49:18So that's kind of been the de facto way of like, it's not really a paper, but you still
- 49:23need to like, you know, share it and get credit for it and put your name on it.
- 49:27It's certainly an issue.
- 49:28I'm starting to see it not even just with software, but even with hardware, because hardware
- 49:32is becoming more open source in our field.
- 49:34And so you just kind of write like a paper about the hardware solution to some problem.
- 49:39That's cool.
- 49:39It's better than a patent.
- 49:40Yeah, it's definitely better than a patent.
- 49:42Patents, while they serve a purpose, are pretty evil.
- 49:45Let's wrap things up with maybe just, you know, you mentioned Continual AI.
- 49:50Tell people a bit about that.
- 49:51It's the largest nonprofit for continual learning.
- 49:54Continual learning in a nutshell is, say I have a neural network and I train my neural network
- 49:59to classify cats.
- 50:01And I classify cats to 90% accuracy.
- 50:03And we're like, yeah, this is why neural networks are great.
- 50:05I take that same trained neural network on cats and I train it on say dogs.
- 50:09It does really well.
- 50:1090% accuracy on dogs.
- 50:12We're really excited why neural networks are so great.
- 50:14But the issue is if I take that, again, the same network, I just trained it on dogs and
- 50:18previously trained it on cats.
- 50:19I try and test it on cats again.
- 50:22It's going to forget pretty much everything it learned about cats.
- 50:26And this is an old, old problem.
- 50:27Back in like, you know, the good old days when neural networks were connectionist models and
- 50:31it was computer scientists, it was the cognitive scientists.
- 50:34They noticed.
- 50:35Overtraining or something like that, right?
- 50:37Kind of overfitting.
- 50:38It's neurorelated.
- 50:39Yeah, it's very similar.
- 50:40Catastrophe forgetting.
- 50:42They call it the sequential learning problem, which is why I'm really interested in it because
- 50:45I'm really interested in, you know, continual learning and sequential memory.
- 50:48Or in neuroscience, it's called the stability plasticity problem.
- 50:51So when do you learn?
- 50:52When do you remember?
- 50:53And so over the last, since we started the organization 2018, the field has kind of exploded
- 51:01just because there's such a need for overcoming this across a lot of use cases.
- 51:06So like a lot of times you can only see the data once.
- 51:09So the way you solve the problem generally is you just shuffle in cats and dogs into the
- 51:14same data set and retrain your model.
- 51:15But now the neural networks are getting bigger and bigger and bigger.
- 51:18Retraining is getting costlier and costlier.
- 51:20You can't just have, you can't train a network on petabytes every time you want to update it.
- 51:24That's even if you have access to the data and the storage to save it and so on and so forth.
- 51:29So clever ways to solve the problem.
- 51:31And so we're kind of around that.
- 51:33We have neuroscientists, we have computer scientists, AI researchers across academia,
- 51:38industry, all that are just a bunch of people really interested in this problem to just come
- 51:42together and share papers, share ideas.
- 51:45We just had a conference.
- 51:46We sponsor a lot of competitions for people to kind of put forward an idea to some problem
- 51:52that we kind of put out every year.
- 51:53So it's been really, really exciting to kind of see the community grow over the years and
- 51:58all the tools and fun things that's kind of come out.
- 52:00Well, it's definitely a hot topic right now.
- 52:02Absolutely.
- 52:02The cognitive scientists and neuroscientists studied neural networks and stuff.
- 52:06And it was kind of like, well, maybe this model stuff.
- 52:08And then now we're in the time of LLMs and the world has gone crazy.
- 52:12Absolutely.
- 52:13I said we were going to close out with a continual AI, but let me just ask, what are your thoughts
- 52:18on LLMs?
- 52:19Where the stuff's going?
- 52:20I mean, we all have exposure to it in different ways, but you've got this understanding of what
- 52:26they're trying to model it on quite a bit.
- 52:28So what do you guys in your space think of it?
- 52:31So the first lab I joined was, well, the first real lab I joined was a neuroscience lab where
- 52:36we were sticking wires in brains and actually doing real neuroscience.
- 52:39But I also started kind of simultaneously working with a cognitive scientist where we were working
- 52:46on the original word to them.
- 52:48So this is, in my mind, like the grandfather of the LLM.
- 52:51So this is the model that like overnight took Google Translate from being meh to pretty good.
- 52:56And it's just really at the heart of it, just an autoencoder.
- 53:00But we were really excited then doing kind of semantic modeling of how much further kind
- 53:06of deep learning could take language modeling.
- 53:08And then we were actually using it to study catastrophic forgetting.
- 53:11So does word to that catastrophically forget?
- 53:13And the punchline is it does.
- 53:15And that kind of got me jumped into really excited about continual learning and so on.
- 53:19So I saw kind of that trajectory then, and then kind of stepped out of it for a few years
- 53:25dug more deep into, you know, pure neuroscience and artificial intelligence from other angles.
- 53:32But I'd always been just so fascinated by this idea of like, say you take an AI and it could
- 53:37read every book or it could read the internet.
- 53:39Like, what would you be able to get?
- 53:41And that was kind of, you know, in my mind, like, well, seeing Word2Vec try and do the same
- 53:46thing and training it on my laptop, like, well, you know, it's going to take, it's going to take a
- 53:50minute till we get there.
- 53:51And I underestimated that drastically.
- 53:55It was like, almost no progress, almost no progress.
- 53:57Wow, what just happened?
- 53:58Right?
- 53:59It's a testament to statistical learning more than anything, which is just how much information
- 54:05can you just soak up and put together in a fancy new way and regurgitate back.
- 54:10I think the next big leap is going to be adding more cognition to that progress.
- 54:15So adding when an agent has a goal, when an agent kind of has to break down a series of
- 54:21steps to get to that goal, those kinds of things we don't see as much of.
- 54:25And that will kind of be the next big push.
- 54:28I think that'll kind of take all the cool things that LLMs can do now and kind of blow everyone
- 54:33away of just, if you can take the internet and put it on a seven gigabyte file, what can
- 54:38that get you?
- 54:39But what if you can take the internet, put it on a seven gigabyte file, but actually have
- 54:42some sort of logic and direction and the agent itself can actually navigate through its
- 54:48own thoughts?
- 54:49That's going to take us, I think, right to the borderline of-
- 54:53Terminator?
- 54:53Yeah.
- 54:53Not Terminator.
- 54:54I'm just kidding.
- 54:55It won't be Terminator.
- 54:55No.
- 54:56It won't be Terminator.
- 54:57But it'll be really an intelligent system.
- 54:59It's going to be super interesting.
- 55:00You know, you've got all this prompt engineering and these clever ways to kind of get the current
- 55:06LLMs in the right mindset, which is probably a personification.
- 55:10But you can tell it things like, here, I want you to tell me how to do this.
- 55:14And I'll come up with some answer.
- 55:15You can say, I want you to think step by step.
- 55:18And then all of a sudden you get a real different type of answer where it pulls out the pieces
- 55:22and it thinks about how it does it.
- 55:23And it's going to be interesting.
- 55:24You know, it's kind of like kind of stuff, but it just, it already knows how to think.
- 55:29You don't have to give it little weird clues.
- 55:31Like you're an expert in this and you're really good at it.
- 55:33Now I want to ask you a question about, oh, I'm good at it.
- 55:35Okay.
- 55:35I'll answer better.
- 55:37My favorite definition of AI is it's whatever computers can't do yet.
- 55:40Yeah.
- 55:40Because like, you know, 30 years ago, if we had this conversation, it'd be like, so what
- 55:44do you think of Deep Blue?
- 55:45Do you think Deep Blue, the AI that becomes probably chess, can, you know, think and is
- 55:51it going to take all our jobs?
- 55:52Or it's going to be, what can Watson do?
- 55:54Can it think and take all our jobs?
- 55:56And, you know, that was solved with tree search, which, you know, undergraduates in
- 56:01their second year CS class are learning.
- 56:02It's just a standard, it's search.
- 56:04People don't even think of search as AI.
- 56:06What if we just loaded every possible outcome into the chess thing and the steps and we just
- 56:11try to take, you know, traverse each step and see where it takes us, right?
- 56:14There's always going to be a room to grow, but, you know, from a cognitive science perspective,
- 56:18I think something far more interesting rather, you know, I think it's cool to see what computers
- 56:22can actually do.
- 56:23And I think they can do a hell of a lot more.
- 56:25But I think it's more interesting to kind of ask the more philosophical question of what
- 56:29does that actually mean for us?
- 56:30Because at every step of the way, when we develop something new in artificial intelligence, it
- 56:34tells us something a lot deeper about our own intelligence too, where back in the 50s and
- 56:3960s, they thought the chess meant intelligence.
- 56:41And so now we're kind of seeing with LLMs, if someone just reads a bunch of books and can
- 56:46memorize a bunch of books, does that mean they're intelligent?
- 56:49Because that's effectively what an LLM can do.
- 56:51It comes across as intelligent, right?
- 56:53It comes across that way to people like, oh, you have all the answers, but it doesn't
- 56:57mean you're good at problem solving necessarily.
- 56:59We're kind of peeling at this onion and we're kind of segmenting intelligence into its different
- 57:03categories to really kind of break it apart just from this vague word of intelligence into
- 57:10actually what are the parts that make something intelligent?
- 57:12What does it really mean?
- 57:14And what are still the things that like we thought were hard and are really easy or the
- 57:18things that we thought were easy and really hard?
- 57:20Because any LLM you have now can't chew gum and walk to the store and buy you something
- 57:25to eat and then play you in chess.
- 57:28And so the general and general AI isn't just there for to make it sound grander.
- 57:34It's there because that's actually something that makes humans very, very unique is that I can
- 57:38have this conversation with you, write code, prepare an omelet, walk a dog and do all of these
- 57:44things all at once.
- 57:45And I started as a babe.
- 57:46And have feelings and thoughts and introspection about it and all that.
- 57:50Hopes, dreams, like ketchup and not tomatoes and all sorts of other.
- 57:53Yeah.
- 57:54Super interesting.
- 57:54So are you, are you pretty positive on, on where stuff's going?
- 57:58I'm less concerned about the AI itself and I'm more concerned about just how we react to it.
- 58:03And if we act, react intelligent, we react well.
- 58:06We went through the industrial revolution.
- 58:08We've went through the steel age.
- 58:10We're starting to go through the cognitive revolution or whatever people are going to call this a hundred
- 58:14years ago.
- 58:15I think by and large, people are going to be okay.
- 58:17I think we just need to, you know, have good policies, make sure that people do it responsibly,
- 58:22people do it well.
- 58:23And that's going to be the hard part is just how do we manage the transition?
- 58:26Well, how do we take a whole labor force whose jobs will be gone?
- 58:31Like there's no economic incentive to keep their jobs and retrain them in a really smart and sensible
- 58:37way.
- 58:37So people's livelihoods don't just go away to, to maximize the dollar.
- 58:42Those are kind of problems that are going to need good policy and clever solutions and a
- 58:48lot of research to actually sit down and handle well.
- 58:51But AI isn't going to go anywhere.
- 58:52Just like computers haven't went anywhere, but it's not Terminator that we should worry about.
- 58:56No, absolutely.
- 58:57It's certainly not.
- 58:58I was joking.
- 58:59We should worry about disinformation and politics and news and all that stuff.
- 59:05I think people get so hung up on all the negatives that we kind of forget.
- 59:08Like we're developing these tools for a reason.
- 59:10Scientists are spending so much time and we're excited about them for a reason.
- 59:13One being that I used to work on proteins, trying to find the structure of proteins.
- 59:17And that was one protein a year.
- 59:20It would take one year to find the structure of protein.
- 59:22And now I can run this.
- 59:23I took the same sequence that we found and ran it through AlphaFold, which is DeepMind's
- 59:27protein folding software.
- 59:29And I could do it in five minutes.
- 59:30I mean, those are the things that will really like catalyze science and technology and healthcare
- 59:35and actually solve the problems we want to solve.
- 59:38So that's what I think we should do.
- 59:40I think I heard even some AI stuff coming up with some new battery chemistry, potentially.
- 59:44Everything.
- 59:45How do you appropriately kind of harness like a fusion ring and like a tokamak reactor or something
- 59:53like that?
- 59:53Everything.
- 59:54Even to how do you route a PCB with like millions of traces affected?
- 1:00:00So it's a tool for the mind and it's not going to put our minds out of work.
- 1:00:05Like you said a long time ago when you were in your eye track.
- 1:00:07Yeah, exactly.
- 1:00:07It's like a different view of that thing.
- 1:00:09The same reason that none of us want to sit around and churn butter and go till the fields
- 1:00:14and walk to work.
- 1:00:16I don't dislike my clothes washer.
- 1:00:19Not at all.
- 1:00:20Yeah.
- 1:00:21Awesome.
- 1:00:21All right.
- 1:00:22Well, thanks for giving us a look inside your lab, inside your research and the field.
- 1:00:27And then just, you know, share what you're about and up to.
- 1:00:29It's been great.
- 1:00:29Yeah, yeah, yeah.
- 1:00:30Thanks for having me.
- 1:00:31Yeah, it's been really great to, at least for the years that I've been in research, seeing
- 1:00:36how pivotal Python has been.
- 1:00:38And I think that's one of the big things that probably goes unnoticed by a lot of developers
- 1:00:43when they're actually writing their code to solve whatever problem they're solving is
- 1:00:46that someone who's wrote the NumPy library or the scikit-learn library or, you know, Jupyter
- 1:00:52Notebooks has actively played a part in curing diseases and making people's lives better.
- 1:00:57And those stories usually don't kind of come to the forefront.
- 1:01:00It's not a direct line, right?
- 1:01:01But the research was done and facilitated by these open source tools and then discoveries
- 1:01:06were made.
- 1:01:07Like you said, that's the difference between people getting cured in 10 years or getting
- 1:01:10cured in a year.
- 1:01:11And that's thousands of lives.
- 1:01:13And so you might not think about it when you're sitting behind your desk, you know,
- 1:01:17making something usable.
- 1:01:18But for every day a PhD student doesn't have to like pull their hair out and debug some software
- 1:01:23when it's well-written and it works well.
- 1:01:24That's a day that they can find something new.
- 1:01:27That's awesome.
- 1:01:27Yeah.
- 1:01:28Very inspiring.
- 1:01:28Let's leave it there, Keelan.
- 1:01:30Thank you for being on the show.
- 1:01:31Absolutely.
- 1:01:32Yeah.
- 1:01:32It's been great to talk to you.
- 1:01:33Thank you so much.
- 1:01:34Yeah.
- 1:01:34Thanks for coming.
- 1:01:34This has been another episode of Talk Python To Me.
- 1:01:38Thank you to our sponsors.
- 1:01:40Be sure to check out what they're offering.
- 1:01:41It really helps support the show.
- 1:01:43It's time to stop asking relational databases to do more than they were made for and simplify
- 1:01:49complex data models with graphs.
- 1:01:51Check out the sample FastAPI project and see what Neo4j, a native graph database, can do
- 1:01:58for you.
- 1:01:58Find out more at talkpython.fm/Neo4j.
- 1:02:03This episode is sponsored by Posit Connect from the makers of Shiny.
- 1:02:07Publish, share, and deploy all of your data projects that you're creating using Python.
- 1:02:11Streamlit, Dash, Shiny, Bokeh, FastAPI, Flask, Quarto, Reports, Dashboards, and APIs.
- 1:02:18Posit Connect supports all of them.
- 1:02:20Try Posit Connect for free by going to talkpython.fm/Posit, P-O-S-I-T.
- 1:02:26Want to level up your Python?
- 1:02:28We have one of the largest catalogs of Python video courses over at Talk Python.
- 1:02:32Our content ranges from true beginners to deeply advanced topics like memory and async.
- 1:02:37And best of all, there's not a subscription in sight.
- 1:02:40Check it out for yourself at training.talkpython.fm.
- 1:02:42Be sure to subscribe to the show.
- 1:02:45Open your favorite podcast app and search for Python.
- 1:02:47We should be right at the top.
- 1:02:49You can also find the iTunes feed at /itunes, the Google Play feed at /play,
- 1:02:54and the direct RSS feed at /rss on talkpython.fm.
- 1:02:58We're live streaming most of our recordings these days.
- 1:03:01If you want to be part of the show and have your comments featured on the air,
- 1:03:04be sure to subscribe to our YouTube channel at talkpython.fm/youtube.
- 1:03:10This is your host, Michael Kennedy.
- 1:03:11Thanks so much for listening.
- 1:03:12I really appreciate it.
- 1:03:13Now get out there and write some Python code.
- 1:03:15Bye.
- 1:03:16Bye.
- 1:03:17Bye.
- 1:03:18Bye.
- 1:03:19Bye.
- 1:03:20Bye.
- 1:03:21Bye.
- 1:03:22Bye.
- 1:03:23Bye.
- 1:03:24Bye.
- 1:03:25Bye.
- 1:03:26Bye.
- 1:03:27Bye.
- 1:03:28Bye.
- 1:03:29Bye.
- 1:03:30Bye.
- 1:03:31Bye.
- 1:03:32you
- 1:03:33Thank you.
- 1:03:35Thank you.