Code covered by the BSD License  

Highlights from

4.6 | 17 ratings Rate this file 54 Downloads (last 30 days) File Size: 14.9 KB File ID: #22114 Version: 1.11




15 Nov 2008 (Updated )

a version of abfload which is capable of reading abf 2.0 files

| Watch this File

File Information

I have taken abfload, and am in the process of updating it for abf 2.0 file formats... so far I have gap free recording working, but haven't finished the other modes.. though they shouldn't be too hard. I would welcome people auditing the code.. i have attached in comments the information from the C file from axon I used to help decode the header information. You can get the C code yourself here

the original abfload can be found here

This is still a work in progress.

Harold Hentschke, the original author of abfload fixed a couple bugs and cleaned up the code, and i am updating this version to include his changes which are:
- fixed a bug regarding the fADCSampleInterval being incorrectly set
- restructured the code so it's easier to see which portions deal with which ABF version
- incorporated all accessory functions as subfunctions
- changed the number type of 'fFileVersionNumber' back to floating point
- updated the copyright note
Further updates from Forrest Collman:
-added support for reading in tags, both in abf 1.0 and 2.0 format
-fixed bug associated with reading in files created in axoscope.
-fixed a bug with my tag support, i had assumed there were tags to be read, should work now on either.

---updates from Harold (06/2011)
bug fixes:

- in the precursor version (abfload) there was a potential problem in the gap-free reading mode: in exceedingly rare cases an error resulted when reading data, namely when division of the number of points by 'chunkPtsPerChan' (see input variable 'chunk') left no remainder

- abfload would only recognize abf files recorded from some of the Axon/MolDev programs (clampex & axoscope). This was due to an incomplete list of programs listed in variable 'progString'. abfload should now read data produced by clampex, clampfit, axoscope and patchxpress

- changes to the tag section which hopefully cover all of the reported problems

other changes:

- some restructuring of code for better oversight and/or in conjunction with bug fixes, modified comments

- data in 'high-speed oscilloscope' mode can now be read (in addition to the two other waveform fixed-length modes)

- right below H1 there is a 'PROBLEM CASE REPORTS' paragraph in which very specific, as yet unresolved problems with abfload (and recording abf files in general) are listed, which may help resolve related issues


Abfload inspired this file.

This file inspired A Panalysis and Load Vclamp Abf.

MATLAB release MATLAB 7.6 (R2008a)
Other requirements Not sure it works on PCs, developed on a mac reading abf files made on a PC.
Tags for This File   Please login to tag files.
Please login to add a comment or rating.
Comments and Ratings (23)
01 Apr 2015 Cengiz Gunay

If you're getting the error

** abfload
Index exceeds matrix dimensions.

Error in abfload>pvpmod (line 1060)
assignin('caller', x{i}, x{i+1});

Error in abfload (line 145)

In Matlab version 2014a, you can fix this by changing line 140 to:

if nargin==2 && ischar(varargin{1}{1}) && strcmp('info',varargin{1})

The only change is in the the ischar check, addressing varargin{1}{1} instead of varargin{1}. It's strange, but it works.

21 Aug 2014 Thijs

Thijs (view profile)

17 Jul 2014 Jeffrey Johnson

Very useful, thank you!

One suggestion - I had some trouble with rounding errors in the calculation of the start point. This appears ultimately to have been due to a badly-written header value for h.fADCSampleInterval (MCDataTool's problem, not yours!) but I was able to partially solve the problem by changing lines 674/683 from FLOOR commands to ROUND commands. I don't understand the use of FLOOR here, since the values on these lines ought to come out integers (subject to rounding error)...we don't want to FLOOR an index value of 4.99999999 to 4!

Also, line 676 appears to be useless. Due to the FLOOR (or ROUND) operation on 674, STARTPT is already an integer. 676 takes the FLOOR of STARTPT*X/X, which certainly won't fix a rounding error but could introduce one. I have commented 676 out to no detriment.

As a side note, if anybody is using MCDataTool to export to .abf, you may have a problem with the value of h.fADCSampleInterval as written to the header. (This is not the fault of ABFLOAD.) If you believe you may be getting frame shifts when reading an .abf written by MCDataTool, feel free to contact me via the email listed in my profile.

18 Mar 2014 Blake Richards

Worked perfectly for me using ABF v2 files with both episodic and gap-free data! Thank you!!!!

26 Jul 2013 James Hounshell  
13 Jun 2013 Forrest Collman

hi scott,

i'm not sure actually. i sent you an email to your yahoo address, if you send me a sample i can take a look.


Comment only
13 Jun 2013 Scott

Scott (view profile)

Sorry if I overlooked something obvious, but I was wondering if there is a way to extract the waveform data (i.e. the command waveform for vclamp experiments) for Abf v2 files. I am (unfortunately) working with both v1 and v2 files. I found that readabf extracts the command waveform info for abf<2 but when I try to use it on abf=2, I get a "maximum variable exceeded" error.
Any advice on how to best extract the command waveform information would be greatly appreciated!

11 Jul 2012 Jonas

Jonas (view profile)


I'm using abf2load for plotting of IV curves from episodic traces.

I'm not very experienced in Matlab. Is there any possibility to extract the clampex comment (which you can manually enter after a each recording) in with abf2load?
I was trying to find it in the code but was unsuccessful so far. Would be nice if someone could give me some advice.

Thanks in advance,

Comment only
29 Jun 2012 wjg

wjg (view profile)

Another bug + fix. If you request a subset of channels, you get them in the order listed in the 'channels' argument. However, if you request all channels, they always are returned in the same order as the file, even if the order given in 'channels' is different. The fix is to change line 674 from:

elseif length(chInd)/h.nADCNumChannels<1


elseif length(chInd)/h.nADCNumChannels<1 || any(chInd ~= 1:h.nADCNumChannels)

Comment only
06 Jun 2012 Matthew

@Ryan and anyone else having the empty goodstart problem:

Look at lines 270 through 275. The name of the program that saved the ABF file is part of the file format. If you saved yours in another program, for instance Clampfit, changing 'axoscope' to the name of the program should work (or, for slightly more robustness, adding a second isempty() check). It solved the problem for me, although it's still a messy hack (as the comments in 270 and 272 do, to be fair, point out).

Comment only
08 Jun 2011 Ryan

Ryan (view profile)

I have the same problems with the tag section, which I have to comment out. Once I do that, the program works about 80% of the time as opposed to about 30% of the time. I also have issues with the following error:

??? Attempted to access goodstart(1); index out of bounds because numel(goodstart)=0.

Error in ==> abfload at 277

Error in ==> Converter at 63

09 Feb 2011 Arthur

Arthur (view profile)

Forrest, I ran into a problem with abf files containing tags. When I try to load them I get the following error:

??? The following error occurred converting from struct to double:
Error using ==> double
Conversion to double from struct is not possible.

Error in ==> abfload at 327

The problem seems to be in the line just before (line 325):


This creates an empty double array, but output of the following loop is a struct. Simply commenting line 325 solved the problem for me.

Thanks again for an otherwise great function.

Comment only
29 Oct 2010 Cengiz Gunay

Apologies.. The file I was trying to load seem to be corrupt and couldn't be loaded by pClamp 10, either. So please ignore the previous post. The correct files can be read by abf2load. Thanks!

27 Oct 2010 Cengiz Gunay

I am getting this error with some ABF2 files from pClamp10:

>> Kslow1_vc = abf2voltage_clamp([ Kfastslow_datadir '008/09821026.abf' ]);
** abf2load
opening ~/prinzlab/Logy/Data Compilation/Potassium Data/Subtracted/008/09821026.abf..
{??? Index exceeds matrix dimensions.

Error in ==> abf2load at 291
h.recChNames=strvcat(h.recChNames, Strings{ADCsec(i).lADCChannelNameIndex});
291 h.recChNames=strvcat(h.recChNames, Strings{ADCsec(i).lADCChannelNameIndex});
K>> ADCsec(i).lADCChannelNameIndex

ans =


There are only about 7000 Strings, so this is way out of bounds. I also tried the python version of abf2load that is part of Neo, but that chokes on these files, too. I can send a copy of the file if you can take a look at it.

Thanks for the otherwise very useful utility!

(molecular devices developer page link is broken now. Is there a way to get to that code?)

18 Aug 2010 Andrius Gaigalas

I can read gap free abf files only if statements 326-329 are comments. This problem was seen before and I thought it was fixed. I have MatLab R2009 student edition runing on MS Vista.

28 Jul 2010 Rune W Berg  
09 Jul 2010 Arthur

Arthur (view profile)

works great!

23 Mar 2010 Julie Haas

Thanks so much! Works great on my episodic data on a PC.

13 Aug 2009 Peter

Peter (view profile)

Works with my episodic stimulation-recording data. Thanks for sharing the code!

29 Jul 2009 Olivier

Olivier (view profile)

28 Jul 2009 Forrest Collman

I have fixed the error that was causing JoAnna's problem

Comment only
21 Jul 2009 JoAnna

JoAnna (view profile)

I commented out line 329, and importing abf v2.0 files seems to work now.

21 Jul 2009 JoAnna

JoAnna (view profile)

Currently, it is unable to run. It appears to have errors in the "tag" support that was recently added. Thus far I have had errors in lines 321 and 329.

19 Nov 2008 1.1

edit) i have fixed one bug.. an indexing error
i think there are problems with the scale factors,
i have had success loading episodic stimulation

25 Nov 2008 1.2

Made the reading of selective channels by name work correctly.

18 Dec 2008 1.3

typo in the description

13 Jan 2009 1.4

included Harold's changes to code, consolidated functions into one m file

15 Jul 2009 1.5

add tag support, also axoscope

21 Jul 2009 1.6

fixed bug when there are no tags

28 Jul 2009 1.7

fixed another tag bug

02 Jul 2011 1.8

Harald fixed some abf 1.0 issues

04 Jul 2011 1.9

added description of most recent changes

16 Aug 2012 1.10

Various bug fixes, reinstating lost updates due to fileexchange bug.

26 Jul 2013 1.11

Fixed bug when channel has no units.

Contact us